Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to connect to a remote Python environment with Pycharm

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Pycharm to connect the remote Python environment". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to connect the remote Python environment with Pycharm".

Preface

This time let's take a look at how to use the Python environment on a remote server on Pycharm.

Why would you do that?

This starts with my experience. I once crawled something for my friend. Because of different categories, I crawled several times. This time, after I wrote the rules, I still crawled normally. Because I was kind-hearted, plus the data volume was not too much, I did not use proxy ip, and the speed of scpay was controlled slowly. Generally, it was only a few minutes. Make a cup of coffee and take a few sips.

However, everything can be an exception. This time, I've had a few cups of coffee, but it's not over yet. Then I looked at the data and found that I was wrong. This category is very complete, and there are many, at least several times as much as before. I can't stop, and I'll ip me soon, and then I'll still wait, wait. Wait and wait, log in for more than an hour, and it's over.

Later, I thought of a problem, if only the code could run directly on the remote server, just write the code and throw it on the remote server, and run it freely.

My environment

Didi Yun ubuntu 18.04 version, Anoconda pycharm2019 Professional Edition has been installed

Note:

Pycharm must be a professional version. Only the professional version can remotely connect to the python environment.

Try to use Anoconda on linux to create an environment to avoid conflicts with the original system pip and to avoid looking for trouble.

Steps

Configure remote server information

Open pycharm and click Tools-- > Deployment-> configuration

Click +-- > SFTP in the upper left corner

Give yourself a name for the remote environment

Configure remote server parameters, as shown in the figure

Configure Connection

Configure Mappings. Once configured, select ok.

View the file Tools-- > deployment-- > Browse Remote Host on the server on pycharm

Be sure to check automatic upload Tools-- > deployment-- > Automatic Upload

Configure the remote python interpreter

We just configured the remote server information above, but did not ask pycharm to specify the python interpreter

Open the interpreter option File-- > settings-- > Project: project name-- > projectInterpreter

Add an interpreter

Select SSH interpreter, configure server information, Next

User password, and then click Next

Select the location of the Python interpreter on the server, and then click Finish

Specify the interpreter as the remote interpreter, and then click Apply,ok

Synchronize files to the server

By default, the entire local project is synchronized to the server's / tmp directory

Crtl+s to automatically synchronize the code to the server

After all the above configuration, you may find that after each writing of the code, it seems that the remote side will not synchronize the code. We need to set it up. Press crtl+s to automatically synchronize the code to the server, and each time the code running on the server is up to date.

Click Tools-- > deployment-- > Options

The configuration is shown in the figure. The red circle must be configured the same, and then click ok.

Applicable scenario

Applicable scenarios are generally reptiles, or need to deal with a task for a long time and so on. After all, it is impossible for me to configure a docker for a crawler.

Or I wrote a little crawler, climbed some jokes and sent them to my goddess every day, and ran them directly on the server, or after the development, the crtl+s was synchronized directly to the server, and there was no need to transfer files or other tedious operations

Thank you for your reading, the above is the content of "how to connect the remote Python environment with Pycharm". After the study of this article, I believe you have a deeper understanding of how to connect the remote Python environment with Pycharm, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report