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 Show All.
, click or expand the list of interpreters, and choose
Configure the list of interpreters
In Add.
, click and chooseChoose the interpreter type to add and perform the specific settings:
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.
In the left-hand pane of the Add Python Interpreter dialog, select System Interpreter.
In the Interpreter drop-down, select one of the Python interpreters that have been installed in your system, or click and in the Select C/C++ Interpreter dialog that opens, choose the desired C/C++ 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: As prompted, consider using a virtual environment for your project.
Click OK to complete the task.
In the left-hand pane of the Add Python Interpreter dialog, select Virtualenv Environment.
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 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 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, 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.
Click OK to complete the task.
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.
In the left-hand pane of the Add Python Interpreter dialog, select Conda Environment.
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 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.
Click OK to complete the task.
In the left-hand pane of the Add Python Interpreter dialog, select Pipenv Environment.
Choose the base interpreter from the list, or click and find the desired Python executable in your file system.
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.
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.
Click OK to complete the task.
In the left-hand pane of the Add Python Interpreter dialog, select Poetry Environment.
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 and find the desired Python executable in your file system.
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.
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/poetryC:\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, 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.
Click OK to complete the task.