CLion 2022.1 Help

Configure Python interpreters

The list of Python SDKs, available for the various projects, can include interpreters installed locally, as well as the virtual environments. The procedure described below supposes that the necessary Python interpreters are already installed on your computer.

View the list of the available interpreters

  • In Settings/Preferences | Build, Execution, Deployment | Python Interpreter, click App general gear plain or expand the list of interpreters, and choose Show All.

Configure the list of interpreters

  1. In Settings/Preferences | Build, Execution, Deployment | Python Interpreter, click App general gear plain and choose Add.

  2. Choose the interpreter type to add and perform the specific settings:

    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.

      creating a virtual environment

      If New Virtualenv is selected:

      1. Specify the location of the new virtual environment in the text field, or click Virtual environment location and find location in your file system. The directory for the new virtual environment should be empty.

      2. Choose the base interpreter from the list, or click Choose the base interpreter and find a Python executable in your file system.

        If CLion 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).

        Downloading Python when creating a virtual env

      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 Existing environment is selected:

      1. Expand the Interpreter list and select any of the existing interpreters. Alternatively, click Select an interpreter and specify a path to the Python executable in your file system, for example, C:\Python36\python.exe.

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

    2. Click OK to complete the task.

    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.

      creating Conda environment

      If New Virtualenv is selected:

      1. Specify the location of the new Conda environment in the text field, or click Conda environment location 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 Conda executable location 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 CLion.

      If Existing environment is selected:

      1. Expand the Interpreter list and select any of the existing interpreters. Alternatively, click Select an interpreter and specify a path to the Conda executable in your file system, for example, C:\Users\jetbrains\Anaconda3\python.exe.

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

    2. Click OK to complete the task.

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

      Adding a system interpreter
    2. When configuring the base interpreter, you need to specify the path to the Python executable. If CLion 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).

      Downloading Python when creating a new project
      Downloading Python when creating a new project

      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:

      System Interpreter warning message
      As prompted, consider using a virtual environment for your project.

    3. Click OK to complete the task.

    1. In the left-handed pane of the Add Python Interpreter dialog, select Pipenv.

      creating Pipenv environment
    2. 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.

    3. If you have not modified the PATH variable, CLion shows an error message: Pipenv executable is not found. Enter the executable path 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.

Last modified: 25 July 2022