matplotlib - 无法在 Tmux 中使用事件的 IPython/Matplotlib 正确退出 SSH session

标签 matplotlib ssh ipython tmux

我遇到了一个问题,即尝试分离一个远程的、事件的 IPython session (通过 Tmux)并导入了 matplotlib,然后退出 SSH 挂起。我必须按 Crtl-C 来终止进程。当我 SSH 回到机器时,tmux 进程消失了。

IPython 示例:

~$ ssh-desk # ssh into remote machine
~$ tmux
~$ ipython
In [1]: import matplotlib.pyplot as plt
Crtl-b Crtl-b d
[detached (from session 0)]
~$ tmux ls
0: 1 windows (created Wed May  2 16:52:58 2018) [78x38]
~$ exit
logout
(process hangs here)
Ctrl-c
~$ ssh-desk
~$ tmux ls
no server running on /tmp/tmux-1000/default

我确实遇到过关于 X11 session 被终止的错误。我认为这是因为我正在使用 ssh -Y 为图形转发 X11。

The X11 connection broke (error 1). Did the X11 server die?

有没有办法在 IPython/Python 中运行 matplotlib 并分离 tmux session 并成功注销?

我在 Linux Mint 18.3(本地和远程机器),IPython 6.3.1

更新 我已经在 google 上搜索了使用 X11 转发分离 tmux session 的所有可能解决方案,但无法使其正常工作,包括将一些 DISPLAY 代码放入 .bashrc 文件中。我也尝试过使用 xpra,但出现无法找到模块 rencode 的错误。

最佳答案

您始终可以退回到 ssh 转义序列:

sequence | description
-------- | -----------
 ~.      | terminate connection (and any multiplexed sessions)
 ~B      | send a BREAK to the remote system
 ~C      | open a command line
 ~R      | request rekey
 ~V/v    | decrease/increase verbosity (LogLevel)
 ~^Z     | suspend ssh
 ~#      | list forwarded connections
 ~&      | background ssh (when waiting for connections to terminate)
 ~?      | this message
 ~~      | send the escape character by typing it twice

进入 tmux 后,如果您只想终止 ssh 连接,请输入例如:

~.

然后您可以再次通过 ssh 连接到服务器并执行:tmux attach

关于matplotlib - 无法在 Tmux 中使用事件的 IPython/Matplotlib 正确退出 SSH session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50144734/

相关文章:

python - pandas 可以在不尝试将索引转换为周期的情况下绘制时间序列吗?

ssh - 如何通过 ssh 进入 GitLab 默认共享运行器?

linux - 如何使用 sudo 权限从 Jenkins 运行远程 ssh session ?

python - Google App Engine 本地(开发)IPython 外壳

python - 在 3D matplotlib 中显示地理引用 DEM 表面

python - tkinter 和 matplotlib : windows not showing until program closes under Linux

python - matplotlib - 调用axes.cla()后,autofmt_xdate()无法旋转x轴标签

python - 使用Paramiko时如何关闭本地回声?

apache - 如何在 Apache 代理后面运行 IPython

zooming - 缩放后的 Ipython Bokeh 散点图标记大小