PyCharm 2016.3 Help

Configuring Remote Python Interpreters

This feature is supported in Professional edition only.

In this section:

Prerequisite

Before you start working with remote interpreters, make sure that the SSH Remote Run plugin is enabled. The plugin is bundled with PyCharm and is activated by default. If it is not, enable the plugin as described in Enabling and Disabling Plugins.

Configuring remote Python interpreter

PyCharm provides full integration with the Python interpreters running on remote hosts.

Note that the name of a remote interpreter is automatically prepended with the prefix Remote.

To configure a remote Python interpreter, follow these general steps

  1. In the Project Interpreter page of the project settings, click /help/img/idea/cogwheel_framed.png.
  2. In the drop-down list, choose Add Remote.
    /help/img/idea/py_interpreter_types_remote.png
  3. Depending on the selection in the dialog box that opens, follow one of the procedures:

Important notes

When a remote Python interpreter is added, at first the PyCharm helpers are copied to the remote host. PyCharm helpers are needed to run remotely the packaging tasks, debugger, tests and other PyCharm features. Next, the skeletons for binary libraries are generated and copied locally. Also all the Python library sources are collected from the Python paths on a remote host and copied locally along with the generated skeletons. Storing skeletons and all Python library sources locally is required for resolve and completion to work correctly in PyCharm.

PyCharm checks remote helpers version on every remote run, so if you update your PyCharm version, the new helpers will be uploaded automatically and you don't need to recreate remote interpreter.

SFTP support is required for copying helpers to the server.

Configuring a remote PHP interpreter in a Docker container

You can quickly bootstrap your PHP application with Docker, PyCharm will take care of the initial configuration by automatically creating a new Dockerfile, keeping your source code up-to-date and installing the necessary dependencies in the container. Configuring a PHP environment running in a Docker container as a PHP remote interpreter lets you run, debug, and profile your PHP application from PyCharm.

Before you start:

  1. Make sure that Docker and Oracle's VirtualBox are downloaded, installed, and configured on your computer as described in Docker.
  2. Configure the PHP development environment in the Docker container to be used.

Learn more about using Docker with PyCharm in Docker.

To configure a PHP interpreter in a Docker container:

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or PyCharm | Preferences for OS X, and click PHP under Languages&Frameworks.
  2. On the PHP page that opens, click the /help/img/idea/browseButton.png button next to the CLI Interpreter drop-down list in the Development environment section.
  3. In the CLI Interpreters dialog box that opens, click the Add toolbar button /help/img/idea/new.png   in the left-hand pane, then choose Remote on the context menu.
  4. In the Configure Remote PHP Interpreter dialog box that opens, choose the Docker method.
  5. In the Server field, specify the Docker configuration to use, see Working with Docker: Process overview. Choose a configuration from the drop-down list or click /help/img/idea/browseButton.png next to it and create a new configuration in the Docker dialog box that opens.
  6. In the Image name field, specify the base Docker image to use. Choose one of the previously downloaded or your custom images from the drop-down list or type the image name manually, for example, php:latest or php:7.0-cli. When you later launch the run configuration, Docker will search for the specified image on your machine. If the search fails, the image will be downloaded from the image repository specified on the Docker Registry page.
  7. Specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment. By default PyCharm suggests the /usr/bin/php folder for remote hosts and Vagrant instances and php for Docker containers. To specify another folder, click the Browse button /help/img/idea/browseButton.png and choose the relevant folder in the dialog box that opens. Note that the PHP home directory must be open for edit.
  8. When you click OK, PyCharm checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, PyCharm displays an error message asking you whether to continue searching or save the interpreter configuration anyway.
    • If the PHP executable is found, you return to the Interpreters where the installation folder and the detected version of the PHP interpreter are displayed.
  9. Optionally, customize the configuration settings of the installation in the Additional area. In the Debugger extension text box, specify the path to Xdebug. This enables PyCharm to activate Xdebug when it is necessary is you have disabled it in the php.ini file, see Configuring Xdebug for Using in the On-Demand Mode.
    • In the Configuration options field, compose a string of configuration directives to be passed through the -d command line option and thus add new entries to the php.ini file. The directives specified in this field override the default directives generated by PyCharm, such as -dxdebug.remote_enable=1, -dxdebug.remote_host=127.0.0.1, -dxdebug.remote_port=9001, -dxdebug.remote_mode=req.

      For example, if you specify the -dxdebug.remote_mode=jit directive it will override the default -dxdebug.remote_mode=req directive and thus switch Xdebug to the Just-In-Time (JIT) mode, see Debugging in the Just-in-Time Mode for details.

      To do that, click the Browse button browseButton.png next to the Configuration options field, and then create a list of entries in the Configuration Directives dialog box, that opens.

      • To add a new entry, click the Add button add.png. In the new line, that is added to the list, specify the name of the new entry and its value in the Name and Value text boxes respectively.

        You can add as many entries as you need, just keep in mind that they will be transformed into a command line with its length limited to 256 characters.

      • To delete an entry, select it in the list and click the Remove button delete.png.
      • To change the order of entries, use the Up arrowUp.png  and Down arrowDown.png buttons.

      Upon clicking OK, you return to the CLI Interpreters dialog box, where the entries are transformed into a command line.

  10. Click the Show phpinfo button to have PyCharm display a separate information window where you can examine the installation details and view the list of loaded extension and configured options. Please note that the options specified in the Configuration Options field of the CLI Interpreters dialog box are not listed.

See Also

Last modified: 23 November 2016