- Configure remote Python interpreters
- Configure an SSH interpreter
- Configure Vagrant
- Configure WSL
- Configure Docker as a remote interpreter
- Configure Docker Compose as a remote interpreter
- Configure a system interpreter
- Configure a system Python interpreter
- Как мне настроить интерпретатор Python в IntelliJ IDEA с помощью плагина PyCharm?
- Create an empty Python project
- To create an empty project:
Configure remote Python interpreters
The following is only valid when the Python plugin is installed and enabled.
IntelliJ IDEA provides full integration with the Python interpreters running on remote hosts.
Before you start working with remote interpreters, make sure that the Vagrant and Docker plugin are installed and enabled. If the plugins are not activated, enable them on the Plugins page of the Settings/Preferences dialog as described in Manage plugins.
Depending on type of the remote interpreter, follow one of the procedures:
Configure an SSH interpreter
Ensure that the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the left-hand pane of the Add Python Interpreter dialog, click SSH Interpreter .
In the right-hand pane select New server configuration , then specify server information (host, port, and username).
Alternatively, you can select Existing server configuration and choose any available deployment configuration from the list.
If needed, click to review the Connection settings, Mappings, and Excluded paths for the selected deployment configuration. Click Next to continue configuring an interpreter.
In the next dialog window, provide the authentication details to connect to the target server.
Select Password or Key pair (OpenSSL or PuTTY) and enter your password or passphrase.
Click Next to proceed with the final configuration step.
In the next dialog window, verify the path to the desired Python interpreter. You can accept default, or specify a different one. You have to configure the path mappings between your local project and the server. To do that, click next to the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.
You can also select the lowest checkbox to enable automatic upload of the local changes to the remote server.
Configure Vagrant
Ensure that a Vagrant instance is created on your machine and properly initialized.
Ensure that the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the left-hand pane of the Add Python Interpreter dialog, click Vagrant :
Click the browse button next to the field Vagrant instance folder , and specify the desired Vagrant instance folder.
This results in showing the link to Vagrant host URL.
The Python interpreter path field displays the path to the desired Python executable. You can accept default, or specify a different one.
Click OK . The configured remote interpreter is added to the list.
Configure WSL
Click the Windows button in the lower-left corner of the screen and start typing System Information . To ensure that your system works well with WSL, upgrade your Windows to the latest available version.
Install the Windows Subsystem for Linux and initialize your Linux distribution as described in the WSL Installation Guide.
Ensure that the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the left-hand pane of the dialog, click WSL .
Select the Linux distribution and specify the path to the python executable in the selected Linux distribution. Typically, you should be looking for wsl.exe but you can specify any non default WSL distro.
Configure Docker as a remote interpreter
Ensure that you have set up Docker on your machine.
Ensure that the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the dialog that opens, select the Docker option, from the drop-down lists select the Docker server (if the server is missing, click New. ), and specify the image name: python:latest .
Python interpreter path should have the default value, for example, python :
Click OK to complete the task.
Configure Docker Compose as a remote interpreter
Ensure that you have set up and run Docker Compose on your machine.
Ensure that the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the dialog that opens, select the Docker Compose option, from the drop-down lists select the Docker server, Docker Compose service (here web ), configuration file (here docker-compose.yml ) and Python interpreter path (here python ).
Next, wait while IntelliJ IDEA starts your Docker Compose configuration to scan and index:
Click OK to complete the task.
For any of the configured Python interpreters (but Docker-based), you can:
Источник
Configure a system interpreter
The following is only valid when the Python plugin is installed and enabled.
To work with your Python code in IntelliJ IDEA, 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 the Python plugin is installed and enabled.
Navigate to File | Project Structure Ctrl+Alt+Shift+S .
In the Project Structure dialog, select SDKs under the Platform Settings section, click , and from the popup menu, choose Python SDK .
In the left-hand pane of the Add Python Interpreter dialog, select System Interpreter .
In the Interpreter field, type the fully-qualified path to the required interpreter executable, or click and in the Select Python Interpreter dialog that opens, choose the desired Python executable and click OK .
If IntelliJ IDEA 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).
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:
Click OK to complete the task.
For any of the configured Python interpreters (but Docker-based), you can:
Источник
Как мне настроить интерпретатор Python в IntelliJ IDEA с помощью плагина PyCharm?
В документации IDEA есть учебник о том, как добавить интерпретатор Python в PyCharm, что включает доступ к странице «Project Interpreter». Даже после установки плагина Python я нигде не вижу этой настройки.
Я упускаю что-то очевидное?
С установленным плагином Python:
- Перейдите в Файл> Структура проекта.
- В меню «Проект» для Project SDK выберите «Создать» и
- Выберите «Python SDK», затем выберите «Локальный».
Если у вас установлен Python SDK, процесс должен быть естественным — перейдите в то место, где находится ваша установка Python.
Итак, вот простой проект, в котором я использовал Selenium и добавил, используя внешний путь
Теперь вам нужно открыть Project Structure и перейти в SDK Раздел
Теперь выберите виртуальную среду вашего проекта. На Classpath вкладке добавьте PYTHONPATH , нажав + кнопку
и теперь модули будут распознаваться
Если в вашем проекте несколько модулей с разными языками, вы можете настроить интерпретатор следующим образом:
- File -> Project Structure.
- Выберите Modules в списке слева
- Выберите модуль Python в списке модулей
- С правой стороны либо выберите существующий Python SDK из раскрывающегося списка, либо нажмите New. кнопку, чтобы создать virtualenv, или создайте новый Python SDK из установки Python в вашей системе.
Следуй этим шагам:
- Открытая настройка ( Ctrl + Alt + s )
- Нажмите на плагины
- Найдите Обзор репозиториев и нажмите
- Искать «питон»
- Выберите Python SDK или pycharm
- Перезагрузите IDE
- Перейти к структуре проекта
- Выберите пакет SDK для Python в проектах или создайте новый проект с помощью SDK для Python.
Я получал сообщение об ошибке (IntelliJ в Ubuntu 18.04), пока был настроен python SDK.
Чтобы исправить это, мне пришлось сделать следующее:
- File -> Project Structure -> Modules
Щелкните Dependencies вкладку, затем щелкните + и выберите пакет SDK для Python.
Нажмите на Apply
После этого предупреждение исчезло, и автозаполнение также начало работать правильно
Источник
Create an empty Python project
The following is only valid when the Python plugin is installed and enabled.
To create an empty project:
From the main menu, choose File | New | Project or on the Welcome screen , click New Project .
New Project dialog opens.
In the left-hand pane of the New Project dialog, select Python as a project type.
In the right-hand pane, specify the project SDK. If the desired SDK is missing in the list, click New and create one of the following Python SDK:
In the left-hand pane of the Add Python Interpreter dialog, select Virtualenv Environment . The following actions depend on whether the virtual environment existed before.
If New environment is selected:
Specify the location of the new virtual environment in the text field, or click and find location in your file system. Note that the directory where the new virtual environment should be located, must be empty!
Choose the base interpreter from the list, or click and find a Python executable in the your file system.
If IntelliJ IDEA 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).
Select the Inherit global site-packages checkbox if you want that 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.
Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in IntelliJ IDEA.
If Existing environment is selected:
Expand the Interpreter list and select any of the existing interpreters. Alternatively, click and specify a path to the Python executable in your file system, for example, C:\Python36\python.exe .
Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in IntelliJ IDEA.
Click OK to complete the task.
In the left-handed pane of the Add Python Interpreter dialog, select Pipenv .
If you have added the user base’s 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.
Click OK to complete the task.
If you have not modified the PATH variable, IntelliJ IDEA shows an error message: Pipenv executable is not found . Discover the proper executable path as described in the pipenv installation procedure and enter the target string in the Pipenv executable field, for example: C:\Users\jetbrains\AppData\Roaming\Python\Python37\Scripts\pipenv.exe (Windows) or /Users/jetbrains/.local/bin/pipenv (macOS).
Click OK to save the changes and complete the task.
In the left-hand pane of the Add Python Interpreter dialog, select Conda Environment . The following actions depend on whether the Conda environment existed before.
If New environment is selected:
Specify the location of the new Conda environment in the text field, or click and find location in your file system. Note that the directory where the new Conda environment should be located, must be empty!
Select the Python version from the list.
Specify the location of the Conda executable file in the text field, or click and find location in the Conda installation directory. You’re basically looking for a path that you’ve used when installing Conda on your machine.
Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in IntelliJ IDEA.
If Existing environment is selected:
Expand the Interpreter list and select any of the existing interpreters. Alternatively, click and specify a path to the Conda executable in your file system, for example, C:\Users\jetbrains\Anaconda3\python.exe .
Select the Make available to all projects checkbox if you want to reuse this environment when creating Python interpreters in IntelliJ IDEA.
Click OK to complete the task.
In the left-hand pane of the Add Python Interpreter dialog, select System Interpreter .
In the Interpreter field, type the fully-qualified path to the required interpreter executable, or click and in the Select Java Interpreter dialog that opens, choose the desired Java executable and click OK .
If IntelliJ IDEA 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).
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:
Click OK to complete the task.
In the left-hand pane of the Add Python Interpreter dialog, click SSH Interpreter .
In the right-hand pane select New server configuration , then specify server information (host, port, and username).
Alternatively, you can select Existing server configuration and choose any available deployment configuration from the list.
If needed, click to review the Connection settings, Mappings, and Excluded paths for the selected deployment configuration. Click Next to continue configuring an interpreter.
In the next dialog window, provide the authentication details to connect to the target server.
Select Password or Key pair (OpenSSL or PuTTY) and enter your password or passphrase.
Click Next to proceed with the final configuration step.
In the next dialog window, verify the path to the desired Java interpreter. You can accept default, or specify a different one. You have to configure the path mappings between your local project and the server. To do that, click next to the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.
You can also select the lowest checkbox to enable automatic upload of the local changes to the remote server.
In the left-hand pane of the Add Python Interpreter dialog, click Vagrant :
Click the browse button next to the field Vagrant instance folder , and specify the desired Vagrant instance folder.
This results in showing the link to Vagrant host URL.
The Python interpreter path field displays the path to the desired Python executable. You can accept default, or specify a different one.
Click OK . The configured remote interpreter is added to the list.
In the dialog that opens, select the Docker option, from the drop-down lists select the Docker server (if the server is missing, click New. ), and specify the image name: python:latest .
Python interpreter path should have the default value, for example, python :
Click OK to complete the task.
In the dialog that opens, select the Docker Compose option, from the drop-down lists select the Docker server, Docker Compose service (here web ), configuration file (here docker-compose.yml ) and Python interpreter path (here python ).
Next, wait while IntelliJ IDEA starts your Docker Compose configuration to scan and index:
Click OK to complete the task.
To add any of the remote interpreters, ensure that the Vagrant and Docker Integration plugin are installed and enabled. If the plugins are not activated, enable them on the Plugins page of the Settings/Preferences dialog as described in Manage plugins.
If needed, select additional libraries and frameworks to enable with the project. When selecting a particular framework, ensure that it is supported by the specified project SDK. Also, provide the required parameters.
On the next page, select the Create project from template checkbox if you want to use a project or framework template for the new Python project.
Источник