Configure a Python interpreter | PyCharm (2024)

Python interpreters in PyCharm

To work with your Python code in PyCharm, you need to configure at least one Python interpreter. You can use a system interpreter that is available with your Python installation. You can also create a Virtualenv, Pipenv, Poetry, or Conda virtual environment. A virtual environment consists of a base interpreter and installed packages.

With PyCharm Professional, you can also configure interpreters to execute your Python code on remote environments: SSH, Vagrant, WSL (only for Windows), Docker, and Docker Compose

Configure a Python interpreter | PyCharm (1)

When you configure a Python interpreter, you need to specify the path to the Python executable in your system. So, before configuring a Python interpreter, you need to ensure that you've downloaded Python and installed it in your system and you're aware of a path to it. You can create several Python interpreters based on the same Python executable. This is helpful when you need to create different virtual environments for developing different types of applications. For example, you can create one virtual environment based on Python 3.6 to develop Django applications and another virtual environment based on the same Python 3.6 to work with scientific libraries.

Python interpreters can be configured for a new project or for the current project (you can create a new interpreter or use one of the existing interpreters).

Setting an existing Python interpreter

At any time, you can switch your Python interpreter either using the Python Interpreter selector or in the project Settings/Preferences.

Change the Python interpreter using the Python Interpreter selector

  • The Python Interpreter selector is located on the status bar. It is the most convenient and quickest way to switch the Python interpreter. Just click it and select the target interpreter:

    Configure a Python interpreter | PyCharm (2)

Change the Python interpreter in the project settings

  1. Press Ctrl+Alt+S to open the IDE settings and select .

  2. Expand the list of the available interpreters and click the Show All link.

    Configure a Python interpreter | PyCharm (3)
  3. Select the target interpreter.

    Configure a Python interpreter | PyCharm (4)

    When PyCharm stops supporting any of the outdated Python versions, the corresponding Python interpreter is marked as unsupported.

When you change an SSH interpreter, you might need to synchronize local content with the target server. Mind a notification balloon in the lower-right corner.

Configure a Python interpreter | PyCharm (5)
You can click one of the links to perform the following actions:

  • Auto-upload files to the server

  • Synchronize files and then enable auto-uploading

Modify a Python interpreter

  1. Press Ctrl+Alt+S to open the IDE settings and select .

  2. Expand the list of the available interpreters and click the Show All link.

    Configure a Python interpreter | PyCharm (6)
  3. Select the target interpreter and click Edit.

    Configure a Python interpreter | PyCharm (7)

    You can specify an alternative interpreter name for the selected interpreter. The Python interpreter name specified in the Name field, becomes visible in the list of available interpreters. Click OK to apply the changes.

    For remote interpreters (that are available in PyCharm Professional) you can modify configuration parameters.

    Configure a Python interpreter | PyCharm (8)

Creating a new Python interpreter

To add a new interpreter to the current project:

  1. Do one of the following:

    • Click the Python Interpreter selector and choose .

    • Press Ctrl+Alt+S to open the project Settings/Preferences and go to . Click Configure a Python interpreter | PyCharm (9) and select Add.

  2. Choose the interpreter type to add and perform the specific settings. For virtual environments and system interpreters, select Add Local Interpreters. For remote interpreters, select a specific type.

    1. In the left-hand pane of the Add Python Interpreter dialog, select Virtualenv Environment. The following actions depend on whether the virtual environment existed before.

      Configure a Python interpreter | PyCharm (10)

      If New Virtualenv is selected:

      1. Specify the location of the new virtual environment in the text field, or click Configure a Python interpreter | PyCharm (11) and find location in your file system. Note that the directory where the new virtual environment should be located, must be empty!

      2. Choose the base interpreter from the list, or click Configure a Python interpreter | PyCharm (12) and find a Python executable in your file system.

        If PyCharm detects no Python on your machine, it provides two options: to download the latest Python versions from python.org or to specify a path to the Python executable (in case of non-standard installation).

        Configure a Python interpreter | PyCharm (13)

      3. Select the Inherit global site-packages checkbox if you want that all packages installed in the global Python on your machine to be added to the virtual environment you're going to create. This checkbox corresponds to the --system-site-packages option of the virtualenv tool.

      If you select any of the existing virtual environments from the Interpreter list, it will be reused for the current project.

    2. Click OK to complete the task.

    See Configure a virtual environment for more details.

    1. If you have added the user base’s binary directory to your PATH environmental variable, you don't need to set any additional options: the path to the pipenv executable will be autodetected.

      Configure a Python interpreter | PyCharm (14)
    2. Click OK to complete the task.

    3. If you have not modified the PATH variable, PyCharm shows an error message: Pipenv executable is not found. Discover the proper executable path as described in the pipenv installation procedure and enter the target string in the Pipenv executable field, for example: C:\Users\jetbrains\AppData\Roaming\Python\Python37\Scripts\pipenv.exe (Windows) or /Users/jetbrains/.local/bin/pipenv (macOS).

      Click OK to save the changes and complete the task.

    See Configure a Pipenv environment for more details.

    1. In the left-hand pane of the Add Python Interpreter dialog, select Poetry Environment. The following actions depend on whether the virtual environment existed before.

      Configure a Python interpreter | PyCharm (15)

      If Poetry Environment is selected:

      1. Select the base Python interpreter from the list, or click Configure a Python interpreter | PyCharm (16) and find its location in your file system.

      2. If PyCharm has not discovered the Poetry path, click Configure a Python interpreter | PyCharm (17) near Poetry executable and navigate to its location. Then click OK in the explorer window to add it to the field.

      If Existing environment is selected:

      1. Expand the Interpreter list and select any of the existing Poetry environments. Alternatively, click Configure a Python interpreter | PyCharm (18) and specify a path to it.

    2. Click OK to complete the task.

    See Configure a Poetry environment for more details.

    1. In the left-hand pane of the Add Python Interpreter dialog, select Conda Environment. The following actions depend on whether the Conda environment existed before.

      If New Virtualenv is selected:

      1. Specify the location of the new Conda environment in the text field, or click Configure a Python interpreter | PyCharm (19) and find location in your file system. Note that the directory where the new Conda environment should be located, must be empty!

      2. Select the Python version from the list.

      3. Specify the location of the Conda executable file in the text field, or click Configure a Python interpreter | PyCharm (20) and find location in the Conda installation directory. You're basically looking for a path that you've used when installing Conda on your machine.

      4. Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in PyCharm.

      If you select any of the existing virtual environments from the Interpreter list, it will be reused for the current project.

    2. Click OK to complete the task.

    See Configure a Conda virtual environment for more details.

    1. In the left-hand pane of the Add Python Interpreter dialog, select System Interpreter.

      Configure a Python interpreter | PyCharm (21)
    2. In the Interpreter field, type the fully-qualified path to the required interpreter executable, or click Configure a Python interpreter | PyCharm (22) and in the Select Python Interpreter dialog that opens, choose the desired Python executable and click OK.

      When configuring the base interpreter, you need to specify the path to the Python executable. If PyCharm detects no Python on your machine, it provides the following options:

      • Specify a path to the Python executable (in case of non-standard installation)

      • Download and install the latest Python versions from python.org

      • Install Python using the Command-Line Developer Tools (macOS only).

      Configure a Python interpreter | PyCharm (23)
      Configure a Python interpreter | PyCharm (24)

      You will need admin privileges to install, remove, and upgrade packages for the system interpreter. When attempting to install an interpreter package through an intention action, you might receive the following error message:

      Configure a Python interpreter | PyCharm (25)
      As prompted, consider using a virtual environment for your project.

    3. Click OK to complete the task.

    See Configure a system interpreter for more details.

    Professional feature: download PyCharm Professional to try.

    1. In the left-hand pane of the Add Python Interpreter dialog, click SSH Interpreter.

    2. In the right-hand pane select New server configuration, then specify server information (host, port, and username).

      Configure a Python interpreter | PyCharm (26)
    3. In the next dialog window, provide the authentication details to connect to the target server.

      Configure a Python interpreter | PyCharm (27)

      Select Password or Key pair (OpenSSL or PuTTY) and enter your password or passphrase. If Key pair (OpenSSL or PuTTY) is selected, specify:

      • Private key file: location of the file with a private key

      • Passphrase: similar to a password, it serves to encrypt the private key.

      The RFC 4716 format for OpenSSH keys is not supported by PyCharm. See the workaround.

      Click Next to proceed with the final configuration step.

    4. In the next dialog window, verify the path to the desired Python interpreter. You can accept default, or specify a different one. You have to configure the path mappings between your local project and the server. To do that, click Configure a Python interpreter | PyCharm (28) next to the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.

      Configure a Python interpreter | PyCharm (29)

      You can also select the lowest checkbox to enable automatic upload of the local changes to the remote server.

    See Configure an interpreter using SSH for more details.

    Professional feature: download PyCharm Professional to try.

    1. In the left-hand pane of the Add Python Interpreter dialog, click Vagrant:

      Configure a Python interpreter | PyCharm (30)
    2. Click the Browse button next to the field Vagrant instance folder, and specify the desired Vagrant instance folder. This results in showing the link to Vagrant host URL.

    3. The Python interpreter path field displays the path to the desired Python executable. You can accept default, or specify a different one.

    4. Click OK. The configured remote interpreter is added to the list.

    See Configure an interpreter using Vagrant for more details.

    Professional feature: download PyCharm Professional to try.

    1. In the left-hand pane of the dialog, click WSL.

      Configure a Python interpreter | PyCharm (31)
    2. Select the Linux distribution and specify the path to the python executable in the selected Linux distribution. Typically, you should be looking for wsl.exe but you can specify any non default WSL distro.

    See Configure an interpreter using WSL for more details.

    Professional feature: download PyCharm Professional to try.

    • In the dialog that opens, select the Docker option, from the lists select the Docker server (if the server is missing, click New...), and specify the image name: python:latest.

      Python interpreter path should have the default value:

      Configure a Python interpreter | PyCharm (32)

      As a result, in the project settings, you should see something like this:

      Configure a Python interpreter | PyCharm (33)

    Click OK to complete the task.

    See Configure an interpreter using Docker for more details.

    Professional feature: download PyCharm Professional to try.

    • In the dialog that opens, select the Docker Compose option, from the lists select the Docker server, Docker Compose service (here web), configuration file (here docker-compose.yml) and Python interpreter path (here python).

      Configure a Python interpreter | PyCharm (34)

      Why we've chosen web? This choice is explained by the fact that after configuring a Docker-Compose-based interpreter, we'll be able to create regular run configurations that will alter the behavior of the container we selected. Therefore, if we want to debug the code in a container, that's the one we should select here.

      Next, wait while PyCharm starts your Docker Compose configuration to scan and index:

    Click OK to complete the task.

    See Configure an interpreter using Docker Compose for more details.

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. 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.

Setting the default interpreter

In PyCharm, you can specify an interpreter that will be automatically set for all newly created projects.

  1. From the main menu, select (on Window and Linux) or (on macOS).

  2. Select Python Interpreter settings. Then either choose an existing interpreter from the Python interpreter list of click Configure a Python interpreter | PyCharm (35) to add a new interpreter. Click OK to save the changes.

    The change will become effective for all newly created projects in PyCharm.

Managing interpreter packages

For each interpreter, you can install, upgrade, and delete Python packages. By default, PyCharm uses pip to manage project packages. For Conda environments you can use the Conda package manager.

Configure a Python interpreter | PyCharm (36)

PyCharm smartly tracks the status of packages and recognizes outdated versions by showing the number of the currently installed package version (column Version), and the latest available version (column Latest version). When a newer version of a package is detected, PyCharm marks it with the arrow sign Configure a Python interpreter | PyCharm (37) and suggests to upgrade it.

By default, the Latest version column shows only stable versions of the packages. If you want to extend the scope of the latest available versions to any pre-release versions (such as beta or release candidate), click Show early releases.

You can upgrade several packages at once. Hold Cmd (macOS) or Ctrl on (Unix or Windows), left-click to select several items in the list of packages, and then click Upgrade.

See the detailed instructions:

  • How to install a package

  • How to upgrade the package

  • How to uninstall the package

See the following video tutorial for additional information:

Last modified: 05 April 2022

Populating Projects Configure a system interpreter

Configure a Python interpreter | PyCharm (2024)

FAQs

Why my PyCharm is showing no interpreter? ›

Edit: If there is no Python interpreter in drop-down menu, you should click the gear icon that on the right of the drop-down menu --> add --> select an interpreter . Show activity on this post. I got the same issue when i newly installed pycharm in my windows 10 machine. install this solved my problem.

How do I add Python 3.9 to PyCharm? ›

2021 How to Install Python 3.9 and PyCharm IDE | Python Tutorial

How do I uninstall Python 2.7 from PyCharm? ›

Python Interpreters

Click this button to select a Python interpreter type from the list. Click this button to delete the selected Python interpreter from the list of available interpreters. Click this button to change name and location of the selected Python interpreter. See the section Configure a Python interpreter.

How do I fix invalid Python interpreter selected for the project? ›

Invalid Python Interpreter selected for the project [2022] - YouTube

What are two ways to run a program using the Python interpreter? ›

There are two ways to use the python interpreter: interactive mode and script mode.

How do I find the Python interpreter path? ›

1 Answer. For finding the full path of the Python interpreter you can use sys. executable which contains the full path of the currently running Python interpreter.

Does PyCharm come with Python interpreter? ›

Local Python Interpreter in PyCharm | Ultimate Beginners Guide - YouTube

Where is Python interpreter located? ›

If you are on a Windows machine, it is most likely the situation that there is a file named C:\Python, and inside that file, there is a program named python.exe. Hence, the path to Python is C:\Python. It can also be installed at the following path: C:\Program Files\Python.

Which Python version is best for PyCharm? ›

Supported languages

PyCharm supports the following versions of Python: Python 2: version 2.7. Python 3: from the version 3.6 up to the version 3.11.

What is the best software for Python? ›

Top Python IDEs
  1. IDLE. IDLE (Integrated Development and Learning Environment) is a default editor that accompanies Python. ...
  2. PyCharm. PyCharm is a widely used Python IDE created by JetBrains. ...
  3. Visual Studio Code. Visual Studio Code is an open-source (and free) IDE created by Microsoft. ...
  4. Sublime Text 3. ...
  5. Atom. ...
  6. Jupyter. ...
  7. Spyder. ...
  8. PyDev.
Jul 20, 2022

Does Python 3.9 have pip? ›

Once the path is added, open a fresh CMD window and type pip --version . Show activity on this post. I found that for Python 3.9 if you enter the command as py -m pip install , the installation initiates as expected.

Is PyCharm free? ›

PyCharm Edu is free to use. The IDE and most of its bundled plugins are built on open source code and licensed under Apache 2.0.

Does PyCharm automatically install Python? ›

PyCharm is our favorite IDE for developing applications with Python. With the release of PyCharm 2020.1, PyCharm can now install the Python interpreter automatically if it does not detect an existing installation.

Does Python install PIP? ›

PIP is automatically installed with Python 2.7. 9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments.

What is the most common Python interpreter? ›

It is the default and most widely-used implementation of the Python programming language. Written in C and Python, CPython is an interpreter that offers a foreign function interface with C and other programming languages.

What is a Python interpreter? ›

The Python interpreter is a virtual machine, meaning that it is software that emulates a physical computer. This particular virtual machine is a stack machine: it manipulates several stacks to perform its operations (as contrasted with a register machine, which writes to and reads from particular memory locations).

Which is best online interpreter for Python? ›

Top 7 Python Interpreters to Execute Python Online
  1. Python Interpreter from Python.Org. ...
  2. PythonAnyWhere's Online Python Interpreter. ...
  3. Python 2. ...
  4. Easy to Use Python Interpreter from SymPy.Org. ...
  5. RexTester's Python Interpreter. ...
  6. IPython Interpreter from TutorialsPoint.Com. ...
  7. Ideone's Python Interpreter.

How does Python interpreter choose VS code? ›

To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

Top Articles
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 5901

Rating: 4.4 / 5 (55 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.