rpi3,直接连接监视器,无法连接到$ DISPLAY代码
问题描述:
尝试在直接连接到rpi3的屏幕上显示UI,mainy实时数据图形和统计信息。
使用一些示例代码中试图显示任何东西,但运行示例代码时,我只能得到一个警告消息:
“警告:QXcbConnection:无法连接到显示”
据我了解,我已经安装了所有的依赖numpy,matlibplot,pyqt5等。假设在视频后面的rpi上启用opwnGL How to Enable OpenGL in Raspberry Pi 不能理解主要问题。首先是有可能在树莓上使用vispy,并有任何建议,我如何连接到我的代码显示?
示例代码:
import numpy as np
from vispy import app
from vispy import gloo
c = app.Canvas(keys='interactive')
vertex = """
attribute vec2 a_position;
void main (void)
{
gl_Position = vec4(a_position, 0.0, 1.0);
}
"""
也试过的例子从Matplotlib Animation Tutorial
但是,这也结束了一个错误: “_thinker.TclError:coulnt连接到显示”
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
// First set up the figure, the axis, and the plot element we want to animate
fig = plt.figure()
ax = plt.axes(xlim=(0, 2), ylim=(-2, 2))
line, = ax.plot([], [], lw=2)
// initialization function: plot the background of each frame
def init():
line.set_data([], [])
return line,
// animation function. This is called sequentially
def animate(i):
x = np.linspace(0, 2, 1000)
y = np.sin(2 * np.pi * (x - 0.01 * i))
line.set_data(x, y)
return line,
// call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=200, interval=20, blit=True)
anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
plt.show()
答
只是想要留下更新:通过使用easy_install更新pyqt5安装来解决它。以前安装的版本(通过sudo apt-get install python3.pyqt5)没有工作
只想保留更新: 通过使用easy_install更新pyqt5安装来解决它。以前安装的版本(通过sudo apt-get install python3.pyqt5)无效 – kitaps