我正在尝试在Windows 10 PC上打开pygame表面。接下来是打开800 x 600窗口所需的步骤。从python shell调用时,曲面会打开并正确显示,如下所示:
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
>>> import pygame
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pygame.init()
(6, 0)
>>> size = (800, 600)
>>> pygame.display.set_mode(size)
<Surface(800x600x32 SW)>
>>> pygame.display.get_surface()
<Surface(800x600x32 SW)>
当我在python脚本中执行相同的操作时,出现回溯错误:
pygame.error: No available video device**
pygame.init()
self.window = pygame.display.set_mode((width, height))
self.screen = pygame.display.get_surface()
self.background = pygame.surface.Surface(self.screen.get_size()).convert()
self.background.fill((0, 0, 0))
pygame.mouse.set_visible(True)
File "C:\Users\timtru\Documents\PycharmProjects\core.py", line 25, in __init__ super(Pypboy, self).__init__(*args, **kwargs) File "C:\Users\timtru\Documents\PycharmProjects\core.py", line 21, in __init__ self.window = pygame.display.set_mode((width, height)) **pygame.error: No available video device**
为什么在脚本中执行相同的步骤时,为什么可以在外壳中获取窗口,但是却得到“无可用的视频设备”?
答案 0 :(得分:0)