CLion 2022.3 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 | 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 | 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. Ensure that you have downloaded and installed Python on your computer.

      Installing Python on Windows from Microsoft Store

      If you are on Windows, you can download Python from the Microsoft Store and install it as a Python interpreter. Once the Python application is downloaded from the Microsoft Store, it becomes available in the list of the Python executables.

      Python interpreter installed from the Windows store
      Note that interpreters added from the Microsoft Store installations come with some limitations. Because of restrictions on Microsoft Store apps, Python scripts may not have full write access to shared locations such as TEMP and the registry.

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

      Adding a system interpreter
    3. In the Interpreter field, type the fully-qualified path to the required interpreter executable, or click the Browse button and in the Select C/C++ Interpreter dialog that opens, choose the desired C/C++ executable.

      Selecting the Python executable

      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.

    4. Click OK to complete the task.

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

      Creating a virtual environment
    2. The following actions depend on whether you want to create a new virtual environment or to use an existing one.

      New virtual environment
      • Specify the location of the new virtual environment in the Location field, or click Virtual environment location and browse for the desired location in your file system. The directory for the new virtual environment should be empty.

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

      • Select the Inherit global site-packages checkbox if you want 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.

      Existing virtual environment
      • Choose the desired interpreter from the list.

      • If the desired interpreter is not on the list, clickApp general ellipsis, and then browse for the desired Python executable (for example, venv/bin/python on macOS or venv\Scripts\python.exe on Windows).

      The selected virtual environment will be reused for the current project.

    3. Click OK to complete the task.

    1. Ensure that Anaconda or Miniconda is downloaded and installed on your computer, and you're aware of a path to its executable file.

      Refer to the installation instructions for more details.

    2. In the left-hand pane of the Add Python Interpreter dialog, select Conda Environment.

      New Conda environment
    3. The following actions depend on whether you want to create a new conda environment or to use an existing one.

      New conda environment
      • Select the Python version from the list.

      • Normally, CLion will detect conda installation.

        Otherwise, specify the location of the conda executable, or click Conda executable location to browse for it.

      • Specify the environment name.

      Existing conda environment
      • Choose the desired environment from the list.

      The selected conda environment will be reused for the current project.

    4. Click OK to complete the task.

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

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

    3. If you have added the base 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.

      If the pipenv executable is not found, follow the pipenv installation procedure to discover the executable path, and then paste it in the Pipenv executable field.

    4. Click OK to complete the task.

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

      creating a poetry environment
    2. The following actions depend on whether you want to create a new Poetry environment or to use an existing one.

      New Poetry environment
      • Select Poetry Environment.

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

      • If CLion doesn't detect the poetry executable, specify the following path in the Poetry executable field, replacing jetbrains with your username:

        /Users/jetbrains/Library/Application Support/pypoetry/venv/bin/poetry
        C:\Users\jetbrains\AppData\Roaming\pypoetry\venv\Scripts\poetry.exe
        /home/jetbrains/.local/bin/poetry
      Existing Poetry environment
      • Make sure that the project directory contains a pyproject.toml file.

      • Select Existing environment. Then expand the Interpreter list and choose the desired interpreter.

      • If the desired interpreter is not on the list, clickApp general ellipsis, and then browse for the Python executable within the previously configured Poetry environment.

      The selected Poetry environment will be reused for the current project.

    3. Click OK to complete the task.

Last modified: 11 January 2023