[Linux] Remote development configuration [Vscode] and [Pycharm]

Table of contents

1. Mobaxterm

2. Vscode

3. PyCharm

4. Summary


When I first came into contact with the Linux system in my sophomore year, the school's servers were all equipped with the Ubuntu system with a graphical interface. Using teamviewer to connect remotely was very convenient, just like having an extra computer. However, after recently entering the institute, I found that the assigned server only has a terminal that can log in using SSH. This makes me, who is spoiled by the various functions of pycharm, very unhappy. I cannot complete code prompts and cannot see all files at a glance. , you cannot debug as you like. . .

So I started a fruitless journey to find a comfortable remote development method, during which I tried mobaxterm, vscode and pycharm. Finally, the usage of each method is summarized.


1. Mobaxterm

It solves the problem that ordinary terminals cannot easily see the file structure and transmit it, and the aesthetics is greatly improved. We can directly create a new SSH session and enter the IP and username and password.

All files are listed on the left and can be dragged and dropped to upload files. On the right is a normal terminal.

2. Vscode

In order to facilitate remote development, Microsoft has launched the component Remote-SSH in recent years. The effect is as follows: This is the vscode software under my windows laptop. The file list and terminal on the left are linked to the remote Linux server. You can directly view and modify the remote python code locally, and you can also use vscode itself. Plug-ins bring functions such as code completion and error prompts.

After closing and reconnecting, the terminal and files that were not closed before will also be automatically displayed. The remote development experience is perfect.

The only shortcoming is that I have used pycharm too much and am not used to vscode. . .

How to operate:

1) Add Remote-SSH and Remote-SSH:Editing in vscode..

                                  

2) Afterwards, an icon will appear on the left . Click on it and set it. Options will pop up automatically. Select the first config file.

3) Configure according to this format in the file,

Host: give it a random name

HostName: Server IP address

User: linux username, such as root

Port: Port number (optional)

                           

4) After the configuration is completed, the server and file root directories will be displayed on the left. Click the folder icon to open the directory. After that, a series of windows will pop up, including entering the password and selecting the system type of the server (linux/windows/mac...). Just fill in the information normally.

                                                 

3. PyCharm

Because I used Jetbrains family bucket before, I am more accustomed to using pycharm to configure remote servers to compile python. However, pycharm remote connection is only available in the professional version (students in school can apply for free professional version by email), and the community version is Can't find the corresponding function. There are two ways to develop Pycharm remotely. One is to open a server file list like mobaxterm, which can facilitate file transfer. Use the local environment to debug the code, and then run the program remotely through the SSH session below. The other is to link the environment with the remote on this basis, use the remote environment to debug the code, and map the server path to the local path for file synchronization. (Personally, I feel that the environment is the same regardless of the environment, so I use the former method)

  • Connection method one operation method (only for remote file transfer, viewing and modification, operation needs to be through a new terminal):

1) Click Tools->Deployment->Configuration above

                                      

2) Create a new SFTP

                                                

3) Enter information such as Host, User name, password, etc. The picture is an example.

                                    

4) After the test is successful and saved, click Tools->Development->Browse remote host, and the server file directory will be displayed on the right. If you need to open a server terminal, just create a new SSH session.

                                       

  • Connection method two operation method (change the interpreter to remote, the server operation is almost the same as your own computer):

1) File->Settings->Project Interpreter (where you configure the environment daily), add a new environment

                           

2) Select SSH Interpreter, the configuration is the same as before.

                       

3) Select an environment location on the server, and check Automatically upload... below, which means to automatically synchronize the local project to the remote server. You can set the synchronization mapping address. After completion, you can use the server environment to run and modify it locally.

                         

4. Summary

In terms of the overall convenience of remote connection, Vscode≥Pycharm≥Mobaxterm. The advantage of Mobaxterm compared to the simplest ssh connection is that it can easily see the file directory and use Notepad to modify the files. Vscode can easily view the running status of the previous terminal, and configure the functions you want through extension plug-ins. Pycharm is somewhere in between.

However, since I am accustomed to Pycharm's code prompts and various convenient operations, I currently use pycharm for code writing and synchronization, and then use vscode to configure the environment, perform code operations, etc.

Guess you like

Origin blog.csdn.net/weixin_42569673/article/details/111481095