How to add interpreter to pycharm
How to add interpreter to pycharm
Configure a system interpreter
To work with your Python code in PyCharm, you need to configure at least one interpreter. A system interpreter is the one that comes with your Python installation. You can use it solely for all Python scripts or take it as a base interpreter for Python virtual environments.
Configure a system Python interpreter
Ensure that you have downloaded and installed Python on your computer.
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.
Do one of the following:
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project
Select Add Local Interpreter from the list of the available interpreter types.
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).
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.
For any of the configured Python interpreters (but Docker-based), you can:
Configure a virtual environment
For Python 3.3+ the built-in venv module is used, instead of the third-party virtualenv utility.
Create a virtual environment
Ensure that you have downloaded and installed Python on your computer.
Do one of the following:
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project
Select Add Local Interpreter from the list of the available interpreter types.
If New Virtualenv is selected:
If PyCharm 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).
If you select any of the existing virtual environments from the Interpreter list, it will be reused for the current project.
Click OK to complete the task.
You can create as many virtual environments as required. To easily tell them from each other, use different names.
Set an existing virtual environment
Press Ctrl+Alt+S to open the IDE settings and select Project
Select the target environment from the list and click OK to confirm your choice.
PyCharm can create a virtual environment for your project based on the project requirements.
Create a virtual environment using the project requirements
Open any directory with your source files that contains the requirements.txt or setup.py file: select File | Open from the main menu and choose the directory.
If no virtual environment has been created for this project, PyCharm suggests creating it:
Keep the suggested options, or specify the environment location or base Python interpreter. Click OK to complete the task.
This approach is particularly helpful when you want to upgrade a version of Python your environment is based on, for example, from 3.5 to 3.9. You can specify a new base interpreter and use requirements.txt to ensure all the needed packages are installed.
For any of the configured Python interpreters (but Docker-based), you can:
Once you have create a new virtual environment, you can reuse it for your other projects. Learn more how to setup an existing environment as a Python interpreter.
Configure an interpreter using WSL
You can use Windows Subsystem for Linux (WSL) to work with a Python interpreter available in your Linux distribution.
Fulfill the preliminary steps
Ensure that you have downloaded and installed Python on your computer.
Install the Windows Subsystem for Linux and initialize your Linux distribution as described in the WSL Installation Guide.
If your Linux distribution doesn’t come with rsync, you need to install it:
sudo apt install rsync
When working with WSL 2, mind the following known WSL issues:
Debugger doesn’t work properly if firewall is not opened for WSL IP.
Configure remote interpreter via WSL
Do one of the following:
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project
Select On WSL from the list of available interpreter types:
Wait until PyCharm detects Linux on your machine and completes introspection. Press Next to proceed:
For a system interpreter, just provide the path to the Python executable in the selected Linux distribution.
For virtual environments, you can provide a path to existing environments in the selected Linux distribution or create a new environment based on the specified Python.
Once done, the new interpreter will be added to your project, and the default mnt mappings will be set.
PyCharm allows you to use custom Linux distributions run on WSL. PyCharm auto-detects such a distribution and adds it to the Linux Distribution list:
Create a WSL-based interpreter for a directory in \\wsl$
If PyCharm cannot discover any pre-configured WSL interpreter, you will see the banner prompting to discover Python in the Ubuntu installation:
Click Search for Python in Ubuntu to find a Python executable and create a WSL-based interpreter.
Once the interpreter is created, PyCharm notifies you.
Configure Terminal in WSL
Switch to the Terminal tool window and type any command to inspect the output.
Configure system settings to enable debugging
Perform the following steps to ensure that the debugger works properly:
Run the Windows PowerShell as administrator.
Execute the following command to allow connections using WSL:
Then execute the command to renew the firewall rules:
Now start the debugger session. When the Windows Security Alert popup appears, select the Public networks checkbox.
Python Interpreters
|
Python interpreters
Click and select Show all. in the Python interpreter settings:
The list of the configured Python interpreters opens:
Use this dialog to configure the list of available Python interpreters.
Tooltip and shortcut
Click this button to select a Python interpreter type from the list.
Click this button to delete the selected Python interpreter from the list of available interpreters.
Click this button to change name and location of the selected Python interpreter. See the section Configure a Python interpreter.
Show virtual environments associated with other projects
If this button is pressed, the virtual environments, already associated with the other projects, are shown in the list of available interpreters.
Show paths for selected interpreter
Click this button to show the list of interpreter paths.
Interpreter paths
This dialog shows up on clicking in the Python Interpreters dialog. It shows the paths where the external libraries reside. If a library has been added, it is recommended to click the Reload button to rescan the Python installation.
Tooltip and shortcut
Click these buttons to add external libraries for the selected Python interpreter.
Click these buttons to remove external libraries for the selected Python interpreter.
Reload List of Paths
Click this button to rescan libraries for the selected Python installation. For example, clicking this button helps update external libraries, if some packages have been upgraded.
Python Interpreter
Use this page to configure and assign a Python interpreter for each of the projects opened in the same window.
Interpreters
The interpreters in the list are configured using the button, as described in the section Viewing list of available Python interpreters.
When PyCharm stops supporting any of the outdated Python versions, the corresponding Python interpreter is marked as unsupported.
This field shows read-only mappings between the desired local path and the corresponding remote path. PyCharm allows configuring paths by clicking next to the field. In the dialog that opens, click
or
buttons to change the path mappings as desired.
Click this button to configure an interpreter:
From the list, choose the one to be added:
Add : choose this option to add a locally residing Python interpreter. This includes also virtual environments and Conda environments. Also, choose this option to add a Python interpreter that resides remotely.
Show all : choose this option to open the list of all interpreters, available to the current project.
Packages
This table shows the packages installed locally.
This column shows the list of packages residing in the accessible remote repositories. For each package you can view its name and repository. Additional information is displayed at the tooltip.
This column shows the currently installed version of a package.
This column shows the latest available versions of the packages. If a version is outdated and the package can be upgraded, mark appears in this column.
Packages toolbar
Tooltip and shortcut
Click this button to install a new package from the accessible remote repositories.
Click this button to uninstall the selected local package.
Click this button to install the latest available version of a package. This button is only available for the outdated package versions.
Show earlier releases
Click this button if you want to extend the scope of the latest available versions to any pre-release versions (such as beta or release candidate ).
Use Conda Package Manager
This button appears for Conda interpreters ONLY!
If this button is pressed, the Conda package manager is used. If this button is released, than pip is used.
The buttons on this toolbar are disabled for the Docker-based and Docker-Compose-based interpreters.
All the packages should be already installed in the Docker image. If some packages are missing, then you will have to create a new Docker image, as described on the page Quickstart Guide: Compose and Django.
Источники информации:
- How to add image to image button
- How to add java path