Skip to end of metadata
Go to start of metadata

PyCharm allows working with the various types of interpreters, and choosing each approach has its pros and contras - it's up to you to decide which one suits better to your particular case.

Note that interpreters can be configured on the various stages of development: when a project is only being created (File | New Project, or Create New Project on the Welcome screen), or in an already existing project (  on the main toolbar - Python Interpreters page).

In this tutorial:

Prerequisite

  • You are working with PyCharm version 3.4 or higher.
  • You have at least one Python interpreter properly installed on your computer.
  • To be abse to define a remote interpreter, you need a server running on a remote host.

Local interpreter

If an interpreter resides locally, the procedure is rather straightforward:

  1. Just click   on the main toolbar.
  2. In the Project Interpreter page of the Settings/Preferences dialog, select the desired interpreter from the list, or click next to the Project Interpreter field.
  3. In the latter case, choose the option Add Local, and then select the desired interpreter - Python executable - from your file system.

It is also worth mentioning that, if you have some virtual environment already defined, you can also add it as a local interpreter.

Remote interpreter

Let's define a remote interpreter, using settings from an SSH connection (note that the server should be already running on a remote host!).

Configuring remote interpreter via existing deployment settings

1. First of all, we need a server. To define one, on the main menu, point to Tools | Deployment, and then click Configuration:

Then, in the Deployment dialog box, create a new server: click  , specify the server name, and select its type (always SFTP!). Specify the necessary settings (host, port, login name etc.) - make sure that you made no mistake by clicking Test connection. Having observed the message box Connection successful!, proceed with the interpreter.

2. Next, on the main toolbar click , and in the Settings/Preferences dialog box, open the page  Project Interpreter. Click and choose Add Remote:

3. In the Configure Remote Python Interpreter dialog box, click the button Deployment configuration to take the settings of the existing SSH server (for example, the one you have already defined).

Choose the desired remote server from the list, and see that all the server setting fields are magically filled with the values, specific for this server:

Now this interpreter can be defined as the project interpreter. Note that all remote interpreter names automatically get the prefix "Remote".

Remote interpreter via SSH credentials

If you do not define a server in advance, you can always specify connection settings manually. To do that, follow this procedure:

1. On the main toolbar click to open the Settings/Preferences dialog box, and on the page  Project Interpreter, click and choose Add Remote:

2. Next, in the Configure Remote Python Interpreter dialog box, click the radio button SSH credentials, and type the server host and port, user name etc.:

Now this interpreter can be defined as the project interpreter. Note that all remote interpreter names automatically get the prefix "Remote".

Remote interpreter via virtual box

Another way of defining a remote interpreter lays with using information from the Vagrant configuration file. Using virtual boxes requires certain prerequisites to be met - so, before you start, make sure that:

  • Vagrant is installed on your computer, and all the necessary infrastructure is created.
  • Oracle's VirtualBox is installed on your computer.
  • The following executables are added to the system path:
    • vagrant.bat from your Vagrant installation. This should be done automatically by the installer.
    • VBoxManage.exe from your Oracle's VirtualBox installation

And, last but not least, Vagrant plugin is enabled.

1. First of all, we need a virtual box. You can certainly do that manually, but PyCharm provides a handy user interface and allows doing everything without leaving the IDE.

On the main toolbar, click , and in the Settings/Preferences dialog, open the page Vagrant.

Specify location of the Vagrant executable, and the path to the Vagrant instance folder:

If the boxes are already defined, they appear in the list, and you can select one. If there are no suitable virtual boxes, create a new one by clicking .

Next, you have to initialize Vagrant box. To do that, on the main menu, point to Tools | Vagrant, and then choose Init in Project Root. After that, you are ready to perform the command vagrant up:

Next, again in the Settings/Preferences dialog box (click on the main toolbar), open the page Project Interpreter. Click and choose Add Remote:

In the Configure Remote Python Interpreter dialog box, you have to specify the server settings. These settings can be taken from the Vagrant configuration file you've already defined, so click the radio button Vagrant.

All the server setting fields are filled with the values, taken from the Vagrant configuration file:

Now this interpreter can be defined as the project interpreter. Note that all remote interpreter names automatically get the prefix "Remote".

For more details, refer to the dedicated Vagrant tutorial.

Creating virtual environment

  1. Open the page Project Interpreter (click on the main toolbar).
  2. Click and choose Create Virtual Environment.
  3. In the Create Virtual Environment dialog box, you have to specify the name of the new virtual environment, its location, and, most important, the base interpreter to create your virtual environment for:

PyCharm spends some time working on the new virtual environment, and in the meantime shows the progress bar:

Working with packages and paths

When an interpreter or a virtual environment is ready, you see all its packages. So doing, PyCharm shows the currently installed and the latest available versions of each package. You can make a decision to upgrade:

To see the installed paths, however, you have to click and then choose More. You see all of the available Python interpreters:

Select the one you want to see paths for, and then click in the toolbar. The list of paths for the selected interpreter show up:

If an interpreter has been updated, it is a good idea to refresh the paths by clicking .

Summary

In this tutorial you've refreshed your knowledge of defining local and various types of remote Python interpreters. It makes sense to refer to the product documentation for more details.

Your Rating: Results: BrokenPartially brokenWorksStableNo problems at all 7 rates
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.