Click " Python crawler and data mining " above to follow
Reply to " Books " to receive a total of 10 e-books of Python from beginner to advanced
now
day
Chickens
soup
Drunk lying does not know the sun and dusk, sometimes looking at the lonely cloud high.
Preface
This time let's take a look at how to use the Python environment on the remote server on Pycharm .
Why did you do this?
This should start from an experience of mine. Once I helped a friend to crawl something. Due to different categories, I divided the crawl several times. This time I wrote the rules and still crawled normally. Because I am relatively kind, In addition, the amount of data is not too much visually, and the proxy ip is not used, and the speed of scpay is relatively slow. When crawling, it usually takes only a few minutes. A cup of coffee is finished after a few sips.
But, but, everything can be exceptions. This time, I have drunk a few cups of coffee, and it is not over yet,!!!, and then I looked at the data and found that I was wrong. This category is very comprehensive. A lot, at least several times the original, this..., I can't stop it, and I will block my ip soon, and then I still wait, wait...wait, wait, log in for more than an hour , It's finally over...
Then I thought of a question. It would be great if the code could be run directly on the remote server. After writing the code, just throw it on the remote server and run it casually.
My environment
滴滴云 ubuntu 18.04版本,已经安装好Anoconda
pycharm2019 专业版
Note:
Pycharm must be a professional version, only the professional version has the function of remotely connecting to the python environment
Try to use Anoconda to create an environment on linux to avoid conflicts with the original system pip and avoid trouble.
step
Configure remote server information
Open pycharm and clickTools ---> Deployment ---> configuration
Click in turn左上角+ --> SFTP
Give yourself a name for your remote environment
Configure the remote server parameters, as shown in the figure
Configure Connection
Configure Mappings , after configuring, select ok
View files on the server on pycharmTools --> deployment --> Browse Remote Host
Be sure to check automatic uploadTools --> deployment --> Automatic Upload
Configure remote python interpreter
Above we only configured the remote server information, but did not let pycharm specify the python interpreter
Open interpreter optionsFile --> settings --> Project:项目名--> projectInterpreter
Add 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 a remote interpreter, and then click Apply, ok
Sync files to the server
By default, the entire local project will be synchronized to the server /tmp
directory
crtl+s, automatically synchronize the code to the server
After the above configuration is completed, you may find that after each code is written, it seems that the remote end will not synchronize the code. We need to set it up and press crtl+s
it to automatically synchronize the code to the server, every time on the server The running code is also the latest code
Click onTools --> deployment -->Options
The configuration is shown in the figure, the red circle part must be configured the same, and then click ok
Applicable scene
The applicable scenarios are generally crawlers, or need to process a certain task for a long time. After all, it is impossible for me to write a crawler to configure a docker.
In other words, I wrote a small crawler, crawling some jokes every day and sending it to my goddess, running it directly on the server, or after the development is completed, crtl+s
it is directly synchronized to the server, without the cumbersome operation of transferring files.
end
If you think the article is okay, remember to like and leave a message to support us, thank you for reading.
If you have any problems during the operation, remember to leave a message below, we will see that the problem will be solved as soon as possible.
Tell others with a smile that I am stronger than yesterday, and I will be the same in the future.
If you want to learn more about Python, you can refer to the learning website: http://pdcfighting.com/, click to read the original text, you can go straight to it~
------------------- End -------------------
Recommendations of previous wonderful articles:
Teach you how to make a simple novel reader with Python
An article summarizes common operations on time in the Python library
Inventory of 5 personalized voice methods based on Python
Welcome everyone to like , leave a message, forward, reprint, thank you for your company and support
If you want to join the Python learning group, please reply in the background [ Enter the group ]
Thousands of rivers and mountains are always in love, can you click [ Looking ]
/Today's message topic/
Just say a word or two~~