我尝试在ubuntu 16.04 vps服务器上运行pygame。它适用于" ssh -X root @ server_ip"。但是当没有-X的ssh连接时,pygame会出错。
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.
答案 0 :(得分:0)
您必须安装适用于Windows的Xming X Server,才能在您的计算机上显示内容。 从此处下载并安装XMing:https://sourceforge.net/projects/xming/然后重试。