PyCharm 2017.3 Help

Configuring Python Interpreter

Introduction

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. In the drop-down list, choose Add local....
    py interpreter types

    The Add Local Python Interpreter dialog box opens:

    py add venv
  3. In the left-hand pane of this dialog, click the Virtual Environment node. The following actions depend on whether the virtual environment existed before.

    If New virtual environment is selected:

    1. Specify the location of the new virtual environment in the text field, or click browseButton and find location in your file system. Note that the folder where the new virtual environment should be located, must be empty!
    2. Choose the base interpreter from the drop-down list, or click browseButton and find the base interpreter in the your file system.
    3. Select the Inherit global site-packages check-box if you want to inherit your global site-packages directory. This check-box corresponds to the --system-site-packages option of the virtualenv tool.
    4. Select the Make available to all projects check-box, if needed.

    If the existing virtual environment is selected:

    1. Specify the required interpreter Use the drop-down list, or click browseButton and find one in your file system.
    2. Select the check-box Make available to all projects, if needed.
  4. Click OK to apply changes and close the dialog box.

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

Configuring a local interpreter

To configure a local Python interpreter

  1. In the Project Interpreter page, click cogwheel framed.
  2. In the drop-down list, choose Add local....
    py interpreter types

    The Add Local Python Interpreter dialog box opens.

  3. In the left-hand pane of this dialog, click System Interpreter.
  4. In the Interpreter field, type the fully-qualified path to the required interpreter executable, or click browseButton and in the Select Python Interpreter dialog box that opens, choose the desired Python executable and click OK.

Configuring a Conda environment

Make sure that Anaconda or Miniconda is downloaded and installed on your computer.

Whether you install Anaconda or Miniconda, depends on you needs.

To configure Conda environment, follow these steps:

  1. In the Settings/Preferences dialog, click Project Interpreter.
  2. In the drop-down list, choose Add local....
    py interpreter types

    The Add Local Python Interpreter dialog box opens.

  3. In the left-hand pane of this dialog, click the Anaconda node. The following actions depend on whether the Conda environment existed before.

    If New Conda environment is selected:

    1. Specify the location of the new Conda environment in the text field, or click browseButton and find location in your file system. Note that the folder where the new Conda environment should be located, must be empty!
    2. Choose the Python version from the drop-down list.
    3. Select the Make available to all projects check-box, if needed.

    If an existing Conda environment is selected:

    1. Specify the required interpreter Use the drop-down list, or click browseButton and find the required Python executable in your file system.
    2. Select the check-box Make available to all projects, if needed.
  4. Click OK to apply changes and close the dialog box.

    The Conda environment is created and added to the list of available interpreters.

Viewing the list of available 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.

To view the list of available interpreters

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. Do one of the following:
    • Click gear icon next to the Project Interpreter field, and in the list of interpreter types, choose Show All....
    • Click the drop-down list in the Project Interpreter field, and choose Show All....
      py show all

    The dialog box Project Interpreters opens.

  3. Choose the desired interpreter and click edit1. The dialog box Edit Python Interpreter appears.
  4. In this dialog, change the interpreter name as required.
    py interpreter rename
Last modified: 29 November 2017

See Also

Concepts: