【发布时间】:2017-06-27 10:41:39
【问题描述】:
我尝试在 ubuntu 16.04 vps 服务器上运行 pygame。它适用于“ssh -X root@server_ip”。但是pygame在没有-X的ssh连接时会报错。
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.
【问题讨论】:
-
-X转发您连接的计算机的图形会话。这样的会话是必需的,通过 SSH 或者您需要服务器上的本地图形登录会话或虚拟帧缓冲区。
标签: python linux opengl ssh pygame