PyCharm 2017.2 Help

Configuring Python Interpreter


In PyCharm you are not limited to using just any single Python interpreter. You are able to implement several and in doing so choose which interpreter you wish to use for any specific project.

PyCharm supports:

Python interpreters can be configured on the following levels:

  • Current project: selected Python interpreter will be used for the current project.
  • New project: selected Python interpreter will be used for the new project instead of the default one.

Configuring Python virtual environment

PyCharm makes it possible to create a virtual environment using the virtualenv tool. PyCharm integrates with virtualenv, and enables configuring virtual environments in the IDE.

virtualenv tool comes bundled with PyCharm, so the user doesn't need to install it.

To configure Python virtual environment, follow these steps:

  1. In the Settings/Preferences dialog, click Project Interpreter.
  2. If the desired virtual environment is missing from the list of available interpreters, click /help/img/idea/2017.2/cogwheel_framed.png and select Create VirtualEnv.

    The Create Virtual Environment dialog box opens.

    Note that only one virtual environment can be configured for a project.

  3. In this dialog box, do the following:
    1. In the Name field, type the name of the new virtual environment, or accept the suggested default name.
    2. In the Location field, specify the target directory, where the new virtual environment will be created, or accept the suggested default location.
    3. From the Base interpreter drop-down list, select one of the configured Python interpreters, which will be used as the base for the new virtual environment.

      If the desired base interpreter is missing in the drop-down list, you can locate it manually by clicking /help/img/idea/2017.2/browseButton.png.

    4. If you want the site-packages of the base interpreter to be visible from the virtual environment, select the check box Inherit global site-packages. If you leave this check box cleared, the new virtual environment will be completely isolated.
    5. The virtual environment can be made available to all your projects, by selecting the check box Make available to all projects.
  4. Click OK to apply changes and close the Create Virtual Environment dialog box.

    The virtual environment is created and added to the list of available interpreters:


Now you can use it as an interpreter for your project.

In the following sections, we'll explore in detail configuring the available Python interpreters and selecting a Python interpreter for a project.

Configuring a local interpreter

To configure a local Python interpreter

  1. In the Project Interpreter page, click /help/img/idea/2017.2/cogwheel_framed.png.
  2. In the drop-down list, choose Add local.
  3. In the Select Python Interpreter dialog box that opens, choose the desired Python executable and click OK.

Note that if there is a virtual environment on your machine, it's also configured as a local interpreter, and is available in the list of available interpreters.

Available Python interpreters

The list of Python interpreters, available for the various projects, can include interpreters installed locally or remotely, and the various virtual environments and Conda environments.

Viewing the list of available interpreters

To view the list of available interpreters, do one of the following

Configuring the list of available interpreters

To configure the list of available interpreters, follow these general steps

  1. Open the Settings/Preferences dialog box, and open the Project Interpreter page.
  2. In the list of interpreter types, choose the desired option:

    Choose More to open the Project Interpreters dialog box, where it is possible to configure the list of the Python interpreters, available on your computer.


Python interpreter for a project

PyCharm helps assign a Python interpreter for a project.

As a result, each one of the projects, opened in the same window, can have an interpreter of its own, selected from the list of available interpreters.

Note that PyCharm stores only the interpreter name in the project settings.

Working on the same project on different platforms

You can work on the same PyCharm project on different platforms (for example, on Windows at work, and on MacOS at home). This can be easily done, if you rename the project interpreter.

The reason is that PyCharm stores the interpreter name with the project, but not the interpreter path.

To rename an interpreter, follow these steps

  1. In the Settings/Preferences dialog, click the page Project Interpreter, and select the desired project.
  2. Click the drop-down list Project Interpreter, and choose Show All.

    The dialog box Project Interpreters opens.

  3. Choose the desired interpreter and click /help/img/idea/2017.2/edit1.png. The dialog box Edit Python Interpreter appears.
  4. In this dialog, change the interpreter name as required.

Note that only this name is stored with the project settings, making it possible to use different interpreters on each platform, without changing the project settings every time you switch to another platform.

Last modified: 26 October 2017

See Also