1. Preparation

Pycharm version 3.4 or higher.

(2) You have at least one Python interpreter installed on your computer.

(3) If you want to configure a remote interpreter, you need server support.

2. Local interpreter configuration

The steps to configure the local interpreter are relatively straightforward:

(1) Click the Settings button on the toolbar.

(2) Select the Project Interpreter page in the Settings/Preferences dialog box and select the corresponding Interpreter version from the Project Interpreter drop-down list, or click the Settings button on the right to manually add the Interpreter.

(3) In the next case, select the Add Local option, and then select the desired interpreter (the Python executable).

It is worth noting that some predefined virtual environments can also be added as interpreters.

3. Remote interpreter configuration

When configuring the remote interpreter, use an SSH connection-based setup (make sure the server already provides responsive remote support).

Configure the remote interpreter with existing deployment Settings

First, we need a server, can through the main menu of the Tools | Deployment, and then click Configuration to define a:

Next click the green plus sign in the Deployment dialog to create a server, enter a name, select the appropriate type (typically SFTP), and any other necessary Settings (host, port, login Name, and so on). After confirming, click Test Connection. Connection Successful! The interpreter connection is successful.

Next, click the Setup button in the main toolbar, open the Project Interpreter page in the Settings/Preferences dialog box, click the Setup icon and select Add Remote:

In the Configure Remote Python Interpreter dialog, click the Deployment Configuration button to set up an existing SSH server (such as the one you defined earlier).

Select the remote service you want from the list. When you are done, you will find that all server Settings have been filled in automatically.

The Remote interpreter can now be used as the interpreter for the current project. Note that all Remote interpreters are named with the prefix “Remote”.

5. Remote interpreter based on SSH certificate

If you did not define the server Settings in advance, you can also manually set up specific connections by following these steps:

1. Click the Settings button on the main toolbar to open the Settings/Preferences dialog box, select the Project Interpreter page, click the Settings button and select Add Remote:

Next, in the Configure Remote Python Interpreter dialog, check the SSH Credentials, and type the server’s Host, port number, user name, and so on:

The Remote interpreter can now be used as the interpreter for the current project. Note that all Remote interpreters are named with the prefix “Remote”.

6. Remote interpreter based on Virtual Box

Another way to define a remote interpreter is through the Vagrant Configuration file. Prepare some work ahead of time before using virtual boxes, so make sure you have some questions before you start:

(1) Vagrant has been installed correctly on the computer, and the associated infrastructure has been created.

(2) Oracle’s VirtualBox has been installed correctly on your computer.

(3) Make sure to add the paths of the following two executables to the system environment variables:

Vagrant. Bat file in the Vagrant installation directory. This step should be done automatically by the installer.

Path to the vboxManage. exe file in Oracle’s VirtualBox installation directory.

Finally, make sure that Vagrant’s plugins work properly.

First of all, you need a virtual box, which we need to configure manually, but Pycharm provides a list of tools to do this in the current IDE environment.

Click the Settings button in the main toolbar to go to the Settings/Preferences dialog box and open the Vagrant page.

Note the path to the Vagrant executable as well as the path to the folder where the Vagrant instance resides:

If the implementation has defined a virtual box, it will appear in the drop-down list for easy selection. If there is no suitable virtual box to choose from, you can create one by clicking the green plus sign.

Next, you need to initialize the Vagrant Box. In the main menu click on the Tools | Vagrant, choose the Init in Project Root, choose the Vagrant up command:

Next go to the Settings/Preferences dialog again, open the Project Interpreter page and select Add Remote:

 

Customize the relevant Settings for the server in the Configure Remote Python Interpreter dialog box, which can be replaced with the previously defined configuration file, so check the Vagrant option.

All server Settings are automatically populated as follows:

The Remote interpreter can now be used as the interpreter for the current project. Note that all Remote interpreters are named with the prefix “Remote”.

See the Dedicated Vagrant Tutorial for more information.

Create a virtual environment

(1) Open the Project Interpreter page (by clicking the Settings button on the toolbar).

(2) Click the Settings icon and select Create Virtual Environment.

(3) Enter the name and location of the new Virtual Environment in the Create Virtual Environment dialog box, and specify the Python interpreter that the Virtual Environment depends on:

While it may take some time to create a virtual environment, Pycharm gives a progress bar to indicate the current creation process:

8. Configure third-party libraries and paths

After you have configured your virtual environment, you will see all the third-party libraries currently installed. Pycharm lists the version of each third-party library currently installed and the latest version of the response, and you can decide whether to upgrade it or not:

To view the installation path, click the Settings button in the dialog box and select More, at which point you can view all available Python interpreters:

Select an interpreter and click the button on the right toolbar to view its path structure:

If an interpreter has been updated, it is best to update its path by clicking on it.

The original link: blog.csdn.net/u013088062/…