Configure Pycharm for remote development


Preface

首先需要你已经拥有一台远程服务器:

  • Remote linux server: 123.23.45.6:12345
    • Username:zzc
    • Password: 111111
    • Conda has been installed (anaconda/miniconda)
  • local windows server
    • Pycharm is in place
    • You can log in to the server via ssh

1. Create a conda environment (remote)

① Log in to the remote client and open the local powershell

ssh -p 12345 -L8888:localhost:8888  [email protected]
  • The port is mapped directly here, and the remote jupyter notebook can be opened in the local browser (it doesn't matter if it is not mapped)

② Create an environment named gnn, the python version is 3.8, and install pip and jupyter notebook at the same time

conda create -n gnn python=3.8 pip jupyter

③ Activate the environment

conda activate gnn

④ Environmental resources required for installation

!pip install numpy pandas matplotlib tqdm networkx -i https://pypi.tuna.tsinghua.edu.cn/simple

Server-side configuration is basically completed


2. Configuration of local Pycharm

1. Create a new project: remote

① Open pycharm and create a new project

New Project

② Configure the remote development environment

1) Select the path>>> Select "Add Interpreter" >>> SSH...
Insert image description here
2) Select "New" >>> ; Fill in the host IP and port number>>> Fill in the user name>>> Next step
Insert image description here
A password is required for the first connection>>> Introspection completed, Click Next
Insert image description here
3) Select the system interpreter>>> Click the three dots on the right to find your own defined environment
Insert image description here
Your conda installation Location/envs/environment name/bin/python
Insert image description here
4) After the interpreter is configured, click Create to complete the project creation
Insert image description here
Wait for the interpreter to update (it will take a few minutes )

③ Test the remote development environment

Create a new jupyter notebook file
Insert image description here
The reference is successful and the remote environment configuration is completed
Insert image description here

2. Synchronize project directory

① In the project menu, select Tools>>> Deployment>>> Configuration
Insert image description here
② In the pop-up window, click ➕ >>> Select SFTP > >> Give a name
Insert image description here
Insert image description here
③ Select the ssh you just created >>> After passing the test, select the project folder on the remote server>>> Encode the communication Change to UTF-8
Insert image description here
Don’t forget to select the check mark in the upper left corner. After selecting, the configuration just created will be bolded

You can see it on the right side of Pycharm File status in the remote folder
Insert image description here
④ Set automatic synchronization
Menu bar>>> Tools>>> Deployment>> > Options, change from Never to Always or Show Save
Insert image description here
so that the saved files will be automatically synchronized to the remote server.
⑤ If there is no automatic synchronization, right-click on the project file and find Deployment in the menu, you can also complete the upload or download

other problems

The configured ssh link can be used in multiple projects.
After the remote environment is configured, it can also be used in multiple projects.

Guess you like

Origin blog.csdn.net/rexxa/article/details/129625832