1

arcade我刚刚在我的 MacBook 上安装了 Python 3 和模块,并正在尝试遵循一个简单的 Hello World 教程: https ://opensource.com/article/18/4/easy-2d-game-creation-python-and-arcade

导入街机作品,但只要我添加下一行以打开一个空白窗口,它只返回一个AttributeError

Traceback (most recent call last):
  File "/Users/nitrox/Code/spielereien/arc-test.py", line 2, in <module>
    arcade.open_window(600, 300, "Drawing Example")
  File "/usr/local/lib/python3.7/site-packages/arcade/application.py", line 384, in open_window
    _window = Window(width, height, window_title, resizable, update_rate=None)
  File "/usr/local/lib/python3.7/site-packages/arcade/application.py", line 53, in __init__
    resizable=resizable, config=config)
  File "/usr/local/lib/python3.7/site-packages/pyglet/window/__init__.py", line 643, in __init__
    self._create()
  File "/usr/local/lib/python3.7/site-packages/arcade/monkey_patch_pyglet.py", line 81, in _create
    self.context.attach(self.canvas)
  File "/usr/local/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_'

不幸的是,在AttributeError with Pyglethttps://github.com/pvcraven/arcade/issues/264中建议的解决方案不起作用。我的工作目录中没有任何名为arcade.pyetc 的文件。

我怎样才能使这项工作?

代码:

import arcade

arcade.open_window(600, 600, "Drawing Example")
arcade.set_background_color(arcade.color.AIR_SUPERIORITY_BLUE)
arcade.start_render()
arcade.draw_lrtb_rectangle_filled(5, 35, 590, 570, arcade.color.BITTER_LIME)
arcade.finish_render()
arcade.run()
4

1 回答 1

1

问题似乎是街机的特定版本(2.0.1)。我已经删除了当前版本:

pip3 uninstall arcade

并重新安装了以前的版本(2.0.0):

pip3 install arcade==2.0.0

这解决了问题并运行示例。

于 2019-04-01T17:56:22.623 回答