Configuring Python Interpreter for a Project
In this section:
PyCharm helps assign a Python interpreter for a project. So doing, each one of the projects, opened in the same window, can have an interpreter of its own, selected from the list of available interpreters.
Note that PyCharm stores only the interpreter name in the project settings.
Selecting Python interpreter for a project
To configure Python SDK for the current project follow these steps:
- Open the Settings dialog box, and click Project Interpreter page.
- In the Projects pane, choose the desired project.
- For the selected project, choose SDK from the list of available Python interpreters and virtual environments.
This list includes:
- Python interpreters, which reside in standard locations.
- Virtual environments, which reside under the project folder, or under the folder specified as
an environment variable
- Other Python interpreters, installed locally or remotely.
- If the desired interpreter is not in the list, click , and configure the desired interpreter as described in the section Configuring Available Python Interpreters. For example, look at the following image:
- Apply changes.
Working on the same project on different platforms
You can work on the same PyCharm project on different platforms (for example, on Windows at work, and on MacOS at home).
This can be easily done, if you rename the project interpreter.
The reason is that PyCharm stores the interpreter name with the project, but not the interpreter path.
To rename an interpreter, follow these steps:
- In the Settings/Preferences dialog, click the page Project Interpreter, and select the desired project.
- Click the drop-down list Project Interpreter, and choose Show All:
The dialog box Project Interpreters opens:
- Choose the desired interpreter and click . The dialog box Edit Python Interpreter appears.
- In this dialog, change the interpreter name as required:
Note that only this name is stored with the project settings, making it possible to use different interpreters on each platform, without changing the project settings every time you switch to another platform.