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

Add Python interpreters

  1. Go to Settings | Build, Execution, Deployment | Python Interpreter.

  2. Click Add Interpreter next to the Python Interpreter field.

  3. Select the interpreter type and set up the configuration:

    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
      • Select the base interpreter from the list, or click Choose the base interpreter and find the Python executable in your file system.

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

      • 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, click , 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.

      For more information, refer to the installation instructions.

    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
      1. Select Conda from the list of environment types.

      2. Select the Python version from the list.

      3. Specify the environment name.

      4. Normally, CLion will detect conda installation.

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

      Existing conda environment
      1. Select the environment from the list.

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

    4. Click OK to complete the task.

    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.

      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 drop-down, select one of the Python interpreters that have been installed in your system, 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 Pipenv Environment.

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

    3. If your project contains Pipfile, you can choose whether you want to install the packages listed in it by enabling or disabling the Install packages from Pipfile checkbox. By default, the checkbox is enabled.

    4. 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 specify it in the dialog.

    5. 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
      1. Select Poetry Environment.

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

      3. If your project contains pyproject.toml, you can choose whether you want to install the packages listed in it by enabling or disabling the Install packages from pyproject.toml checkbox. By default, the checkbox is enabled.

      Existing Poetry environment
      1. Make sure that the project directory contains a pyproject.toml file.

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

      3. If the required interpreter is not on the list, click , 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.

Set up a Python interpreter for the project

  1. After you configure Python interpreters, you can select one of them from the list:

    The list of the available Python interpreters
  2. Click Apply to set the selected interpreter for your project.

Last modified: 09 October 2024