Using Python on a remote server using PyCharm

I started learning Python, and so far my setup has been as follows: Installing Python 3.5 on a 64-bit Win10 local machine with PyCharm as a great development environment. Everything works, matplotlib graphs and other visual outputs display small, debugging work, etc.

Now I came across some libraries that only work on Linux. I installed Ubuntu 16.4 64bit VPS on Digital Ocean, installed Python 3.5. In PyCharm, I established an SFTP connection with a remote host. Working with code works, debugging work, however, I can’t bring the display of output (matplotlib graphics, ...) to the local machine (Win10). Since I am not at all familiar with Linux GUI environments (X11?), After searching the Internet, I have the following questions:

1) Should any device be installed on the remote Linux computer? (e.g. x11 client / server / smth?)

2) Should it be installed on the local Win machine? (e.g. Xming?)

3) Should there be any settings on the remote Linx machine? (e.g. X11 call forwarding)

4) Should it be configured on a local Win PyCharm machine?

5) Putty has X11 forwarding settings, and some of them suggested using them, but I'm not sure if a Putty session should start in parallel with PyCharm, and this can be avoided.

Thanks a lot!

PS - I installed the Jupyter Notebook (and the latest Jupyter Lab) on the remote machine and it works great, however I still prefer PyCharm as the main IDE with improved code completion, debugger and other benefits.

+5
source share
1 answer

Well, after a few more searches, I finally managed to get this process to work, hope this helps someone:

1) on the remote host (VPS, Ubuntu 16.04) I had to install the X11 server, which I did:

sudo apt-get install xorg sudo apt-get install openbox 

2) On the remote host, I had to make sure that X11Forwarding is included in / etc / ssh / sshd _config

3) On the local Win10 machine, I had to install the Xming server and run it with the default settings.

4) On the local Win10 machine, I had to configure Putty to use X11 forwarding (Connection-> SSH → X11 Forwarding) with the default settings and disconnect the connection when PyCharm starts (it seems that PyCharm cannot enable x11 forwarding, so putty should work in the background mode)

5) On the remote machine, I needed to check the display number (echo $ DISPLAY) - this can be different for everyone. For me it was localhost: 10.0

6) In the configuration of PyCharm Run -> environment variables I had to add DISPLAY = localhost: 10.0

After all these steps and Putty + Xming working in backgroud, I was able to execute the remote code and return the graphics to my Windows 10 computer!

PS - the process is actually slow, I need to wait about 10 seconds until the image returns to me. I’m not sure why and how to speed it up. Maybe another question. (decreasing the strength of encryption and allowing compression, this does not help. It seems to be something like a problem with initialization with remote and local x11)

+6
source

Source: https://habr.com/ru/post/1257561/


All Articles