In PyCharm, you can debug a Python script remotely. For remote debugging, PyCharm provides:

The process of remote debugging involves the following general steps:

  1. Open the Run/Debug Configuration dialog box, as described in the section Creating and Editing Run/Debug Configurations, and select the Python Remote Debug configuration type.
  2. Specify the local host name and the number of the port where the debug server will run. If you don't specify any value, PyCharm will provide port number at random.

    If remote debugging is performed with a remote Python interpreter, then everything is done within a single SSH connection, and port numbers are not required.

  3. If you are going to debug a script that resides on a remote machine, specify the source root of the remote script, and the root of the local sources to keep mapping.
  1. Locate your remote script, and launch it as required by your specific operating system. For example, on Windows, use the command:

    python <script name>

    If the corresponding local script exists, PyCharm opens it in the editor in the suspended mode; the first executable statement is marked with the blue stripe. Also, PyCharm shows the frames and variables for its first executable statement in the Debug tool window. If the corresponding local script cannot be found, PyCharm opens a dedicated editor tab, and suggests you to do one of the following:

    • Edit the local and remote roots in the remote debug configuration dialog box.
    • Detect the mapping files automatically, and then select the one to be used as the local version from the list of encountered files with the matching names.
    • Download the remote file to the specified location.
  2. Step though the script and explore frames.

See Also

Concepts:

Language and Framework-Specific Guidelines:

Reference:

Web Resources: