Python 可以在ubuntu vps服务器上运行pygame吗?
我尝试在ubuntu 16.04 vps服务器上运行pygame。它与“ssh-X”一起工作root@server_ip". 但是当ssh连接没有-X时,pygame会给出错误Python 可以在ubuntu vps服务器上运行pygame吗?,python,linux,opengl,ssh,pygame,Python,Linux,Opengl,Ssh,Pygame,我尝试在ubuntu 16.04 vps服务器上运行pygame。它与“ssh-X”一起工作root@server_ip". 但是当ssh连接没有-X时,pygame会给出错误 pygame.display.set_mode((self.w, self.h),DOUBLEBUF|OPENGL) pygame.error: No available video device 我在服务器上安装了x11,它可以正常工作。尽管如此,pygame错误仍在继续 code :
pygame.display.set_mode((self.w, self.h),DOUBLEBUF|OPENGL)
pygame.error: No available video device
我在服务器上安装了x11,它可以正常工作。尽管如此,pygame错误仍在继续
code :
os.environ['SDL_VIDEODRIVER'] = 'x11'
pygame.init()
pygame.display.set_mode((self.w, self.h),DOUBLEBUF|OPENGL)
x11 status:
root@vps423325:~# service x11-common status
● x11-common.service - LSB: set up the X server and ICE socket directories
Loaded: loaded (/etc/init.d/x11-common; bad; vendor preset: enabled)
Active: active (exited) since Tue 2017-06-27 00:15:02 CEST; 11h ago
Docs: man:systemd-sysv-generator(8)
Process: 1002 ExecStart=/etc/init.d/x11-common start (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
Jun 27 00:15:02 vps423325 systemd[1]: Starting LSB: set up the X server and ICE socket directories...
Jun 27 00:15:02 vps423325 x11-common[1002]: * Setting up X socket directories...
Jun 27 00:15:02 vps423325 x11-common[1002]: ...done.
Jun 27 00:15:02 vps423325 systemd[1]: Started LSB: set up the X server and ICE socket directories.
您必须安装Xming X Server for Windows才能使其工作并在您的计算机上显示内容。
从此处下载并安装XMing:然后重试。
-X
转发您从中连接的计算机的图形会话。这样的会话是必需的,可以通过SSH,也可以通过服务器上的本地图形登录会话或虚拟帧缓冲区。我的目的是将pygame脚本作为后台任务运行,以由http请求触发。我认为,如果pygame脚本将在SSH终端中运行,而不使用-X,它可以作为服务器脚本运行。这是错误的吗?因此您需要运行pygame headless,您正在将视频驱动程序设置为x11
:os.environ['SDL\u VIDEODRIVER']='x11'
而不是将其设置为x11
尝试将其设置为dummy
或fbcon
。在os.environvironment['SDL\u VIDEODRIVER']='x11'更改os.environment之后['SDL\u VIDEODRIVER']='dummy',我得到了一个新的错误“pygame.error:OpenGL不可用”。我用“sudo apt get install python OpenGL”安装了python OpenGL。此外,glxinfo命令给出了输出“error:cannot open display”。OpenGL配置中是否有错误?