r/Python • • Aug 26 '18

Remote Python & IDE workflow?

Hi! I'm looking for a way to use a remote Python interpreter (in my case it's a docker container on another machine) with an IDE like Pycharm or VS Code. In principle, it seems possible using just pycharm "remote interpreter" feature, althrough it requires SSH access into that container which I would prefer not to install if possible. Another major piece I have no idea how to make working is plots. I don't need interactive plots, just jupyter-style static ones will work. This sounds like a quite common usecase, but I couldn't find any help on how to set it up. For now I use jupyterlab running in that docker container, but really miss autocomplete and other stuff offered by IDEs. Any pointers welcome!

1 Upvotes

32 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 29 '18

Alright, in that case, the easiest way of handling would be to set up SFTP deployment to transfer the files from the IDE to the Docker host. In turn, use a volume to get these files into the container.

You can configure SFTP deployment in Tools | Deployment. After this everything should work.

Let me know how things go!

1

u/aplavin Aug 29 '18

Ok then, and what do you think about plots?

1

u/[deleted] Aug 29 '18

Checked with the developer, these should work without additional issues.

1

u/aplavin Aug 29 '18

Indeed, this way I managed to setup it to run scripts, using SFTP deployment and docker running. It required manually setting volume paths as I don't see a way to reuse the already existing docker compose file on the remote machine. However, this is a minor issue.

Also I cannot get the console and plots working. The console just doesn't start saying "Error:Host address cannot be detected for tcp://localhost:12375 Docker connection" (it's localhost because I use ssh port forwarding to access the remote machine). And when I try to make plots with matplotlib (including plt.show() command) with a script, nothing shows up, even in the "plots" panel of scientific mode.

1

u/[deleted] Aug 30 '18

Ah okay, if your Docker host is on a different network this will be hard to get to work. PyCharm uses a random port to connect to debuggers / python console

Let me think if there's a way to get this to work, I'm not sure if there is a way other than a VPN though.