使用 PyCharm 在远程服务器上绘制 Python [英] Python plotting on remote server using PyCharm

查看:74
本文介绍了使用 PyCharm 在远程服务器上绘制 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习Python,到目前为止,我的设置一直在进行-在Win10 64位本地计算机上安装Python 3.5,并使用PyCharm作为出色的IDE.一切正常,matplotlib 图表和其他可视化输出显示正常,调试正常等.

I have started to learn Python and so far my setup has been following - Python 3.5 installation on Win10 64bit local machine with PyCharm as a great IDE. Everything works, matplotlib charts and other visual outputs display fine, debugging works, etc.

现在,我遇到了一些只能在Linux上运行的库.我已经在 Digital Ocean 上设置了 Ubuntu 16.4 64bit VPS,安装了 Python 3.5.在PyCharm中,我已经建立了到远程主机的SFTP连接.代码运行正常,调试正常,但是,我无法将显示输出(matplotlib 图,...)带到本地(Win10)机器.由于我完全不熟悉 Linux GUI 环境(X11?),在谷歌搜索后我有以下问题:

Now, I have came across some libraries which works only on Linux. I have set up Ubuntu 16.4 64bit VPS on Digital Ocean, installed Python 3.5. In PyCharm I have set up SFTP connection to remote host. Code running works, debugging works, however, I am not able to bring display output (matplotlib plots,...) to local (Win10) machine. As I am not at all familiar with Linux GUI environments (X11?), after googling I have following questions:

1)远程Linux机器上应该安装任何东西吗?(例如x11客户端/服务器/智能手机?)

1) Should anything be installed on remote Linux machine? (e.g. x11 client/server/smth?)

2)是否应在本地Win机器上安装任何软件?(例如Xming?)

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

3)是否应在远程Linx机器上进行任何配置?(例如X11转发)

3) Should anything be configured on remote Linx machine? (e.g. X11 forwarding)

4) 是否应该在本地 Win 机器 PyCharm 上配置任何内容?

4) Should anything be configured on local Win machine PyCharm?

5)Putty中有X11转发设置,有些建议使用这些设置,但我不确定,Putty会话是否应与PyCharm并行运行,并且可以避免.

5) There are X11 forwarding settings in Putty and some have suggested to use those but I am not sure, should Putty session run in paraller with PyCharm and can that be avoided.

非常感谢!

PS - 我已经在远程机器上安装了 Jupyter Notebook(和最新的 Jupyter Lab)并且它运行良好,但是我仍然更喜欢 PyCharm 作为主要 IDE,具有更好的代码完成、调试器和其他特权.

PS - I have installed Jupyter Notebook (and latest Jupyter Lab) on remote machine and it works excellent, however I am still prefering PyCharm as primary IDE with better code completion, debugger and other perks.

推荐答案

好的,经过更多的谷歌搜索后,我终于设法使这个过程正常工作,希望对某人有所帮助:

Ok, after some more googling I finally managed to get this process working, hope it helps somebody:

1)在远程主机(VPS,Ubuntu 16.04)上,我必须安装X11服务器,我可以通过以下方式安装:

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

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

2)在远程主机上,我必须确保在/etc/ssh/sshd_config中启用了X11Forwarding

2) On remote host I had to make sure that X11Forwarding is enabled in /etc/ssh/sshd_config

3)在本地Win10计算机上,我必须安装Xming服务器并使用默认设置启动它.

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

4) 在本地 Win10 机器上,我必须将 Putty 配置为使用默认设置的 X11 转发(连接-> SSH -> X11 转发)并在运行 PyCharm 时保持连接打开(似乎 PyCharm 中没有启用 x11 的选项转发,因此腻子必须在后台运行)

4) On local Win10 machine I had to configure Putty to use X11 forwarding (Connection-> SSH -> X11 Forwarding) with default settings and keep connection open while running PyCharm (it seems there is no option in PyCharm to enable x11 forwarding, so putty must be running in the background)

5) 在远程机器上,我必须检查显示编号 (echo $DISPLAY) - 这对每个人来说都是不同的.对我来说是 localhost:10.0

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

6)在PyCharm Run配置中->环境变量,我必须添加DISPLAY = localhost:10.0

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

在所有这些步骤和 Putty+Xming 在后台运行之后,我能够执行远程代码并将图形带回我的 Windows 10 PC!

After all these steps and Putty+Xming running in backgroud, I was able to execute remote code and bring graphic back to my Windows 10 PC!

PS - 过程实际上很慢,我必须等待大约 10 秒钟才能将图像带回给我.我不确定为什么或如何加快速度.可能是另一个问题.(降低Chipher强度并启用压缩无济于事.这似乎是x11远程和本地的某种初始化问题)

PS - process is actually slow, I have to wait around 10 seconds before image is brought back to me. I am not sure why or how to speed it up. Might be another question. (reducing chipher strength and enabling compression does not help. It seems some sort of initialization problem with x11 remote and local)

这篇关于使用 PyCharm 在远程服务器上绘制 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆