gpt4 book ai didi

python - Tcl 错误 : no display name and no $DISPLAY environment variable on EC2

转载 作者:太空狗 更新时间:2023-10-29 17:50:34 28 4
gpt4 key购买 nike

我想在 Amazon EC2 (Linux AMI) 上使用 iPython。我已经安装了 Anaconda 并启动了 iPython 来测试我已经创建的一些脚本。现在我只对在终端中运行它感兴趣(不是作为笔记本)。

在我的代码开头,我总是这样做:

import json
import numpy as np
import pandas as pd
from pandas import Series, DataFrame

但是,我在我的文本编辑器中尝试了 CTRL + C,然后在终端中使用 %paste 我得到了错误:

TclError: no display name and no $DISPLAY environment variable

如果我按照这个建议尝试 ssh -X name@host No display name and no $DISPLAY environment variable using tkinter through ssh ,我得到:

/opt/X11/bin/xauth:  file /Users/adrianp/.Xauthority does not exist
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
X11 forwarding request failed on channel 0

为了解决这个问题,我尝试了 https://superuser.com/questions/249045/x11-forwarding-from-amazon-ec2-ami但仍然收到警告:

 Warning: untrusted X11 forwarding setup failed: xauth key data not generated

同样的错误:

TclError: no display name and no $DISPLAY environment variable

根据这个建议 Generating a PNG with matplotlib when DISPLAY is undefined (这似乎无关紧要,但我已经尝试了一切)我做到了:

import matplotlib
matplotlib.use('Agg')

在导入任何其他内容之前仍然出现相同的错误。

关于如何解决这个问题有什么想法吗?我真的很想使用粘贴魔术功能来输入函数等。

最佳答案

这更像是一个 linux/X11 问题而不是 python 问题。此外,这个过程可能会过大 - 你最好只在本地运行 ipython 或启动网络笔记本。

无论如何,你应该:

  • 安装tigervnc
  • 运行 vncserver(因为这是面向 Internet 的服务器,请使用安全密码或在防火墙中阻止端口)
  • 安装 tk(我想你已经完成了)
  • 编辑 sshd_config(很可能是/etc/ssh/sshd_config)并启用X11Forwarding(X11Forwarding 是)。
  • 登录到您的服务器,将 -Y 选项传递给 ssh (ssh -Y user@server)

然后您应该能够启动 ipython 并使用 %paste。

关于python - Tcl 错误 : no display name and no $DISPLAY environment variable on EC2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28905725/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com