我是编程课程的助教。本周的挑战是构建一个基本的国际象棋游戏。老师创建了一个game.py
可以帮助他们的库。问题是,当使用LostGame
定义如下(并使用库Arcade
)的类时:
class LostGame(arcade.Window):
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
self.sprites_list = None
self.background = None
arcade.set_background_color(arcade.color.RED)
self.moves = []
self.doing = 0
self.started = 0
self.current_text = "Comienza el juego"
我们将会出现以下错误:
Traceback (most recent call last):
File "test.py", line 4, in <module>
juego = game.LostGame()
File "/Users/daniel/Documents/Doctorado/Ayudantías/IIC2115/L02/game.py", line 39, in __init__
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/arcade/application.py", line 53, in __init__
resizable=resizable, config=config)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/window/__init__.py", line 643, in __init__
self._create()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/arcade/monkey_patch_pyglet.py", line 81, in _create
self.context.attach(self.canvas)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/gl/cocoa.py", line 289, in attach
self._nscontext.setView_(canvas.nsview)
AttributeError: 'NoneType' object has no attribute 'setView_'
我们注意到这个错误会发生在所有安装了 Anaconda 的计算机上。我们认为这可能是因为 Anaconda 的 Python 无法识别该Arcade
库。我们已经在 的独立版本上运行了代码Python 3.7
,但没有成功。
在此先感谢您的帮助!