pycharm remotely connects to the server through ssh and runs the code

First connect to the remote server, tool->deplayment->configuration

Connect to ssh, click +, select SFTP, and then name it

Click... behind ssh and enter the IP, username, and password of the remote server in sequence.

Click test connection to test whether the connection is successful

Click OK to return to the previous interface. The root path is the path of the server. You can not select it, but it will be too verbose after remote host. You can select the path according to the actual situation.

Click mappings to set the mapping path. The local path is the local project path. The default is enough. The deployment path is the path uploaded to the server. The local code will be submitted to this path.

Click OK when setting is complete.

tools->deployment->browse remote host, remote host will pop up. If it is not displayed, click the inverted triangle to select the set SFTP. As shown below, the connection is successful

Interpreter configuration

File->Settings->Project->python interpreter

Click the gear and select add. (Note that multiple interpreters will affect the operation. To be on the safe side, select show before adding an interpreter to see if there are any redundant interpreters. If there are, delete them)

Click ssh, select an existing environment, and select your own ssh from the drop-down menu

Click next (the first connection will display a dialogue below, just click the move)

interpreter is the location of the server interpreter. Generally, there is no need to change it. If it does not exist, click on the file icon next to it, find the path, and select the python interpreter there.

sync folers, the mapping between the local path and the remote path on the server, you can choose the default, or you can choose it yourself

After confirming, click finish

The interpreter is configured successfully as follows:

Code upload and download

Download, find the file path previously configured in mapper, right-click download

After success, a py file will appear locally. Run the py file. If the following results are obtained, it is successful.

To upload, select upload

Supongo que te gusta

Origin blog.csdn.net/m0_56122800/article/details/129417470
Recomendado
Clasificación