0

I have installed Python Arcade using

pip install arcade

which ran successfully.

When trying to run the example code, or even just trying to import arcade from the Python command line, I receive an error

>>> import arcade
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/brian/.local/lib/python3.8/site-packages/arcade/__init__.py", line 250, in <module>
    from .joysticks import get_game_controllers
  File "/home/brian/.local/lib/python3.8/site-packages/arcade/joysticks.py", line 1, in <module>
    import pyglet.input
  File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/__init__.py", line 179, in <module>
    from .evdev import get_devices as evdev_get_devices
  File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py", line 509, in <module>
    class EvdevControllerManager(ControllerManager, XlibSelectDevice):
  File "/home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py", line 583, in EvdevControllerManager
    def get_controllers(self) -> list[Controller]:
TypeError: 'type' object is not subscriptable
>>> 

Python version is 3.8.10, and OS is Ubuntu 20.04, but I can't get past this error.

Brian
  • 101
  • 1
  • Thanks - the page with installation instructions just says "The Arcade library is Python 3.7+ only." , so I thought I would be OK. – Brian Jun 03 '22 at 09:42
  • That's a bug in `pyglet` introduced recently and fix in [Github](https://github.com/pyglet/pyglet/blame/master/pyglet/input/evdev.py#L585) already. Try to install an older version of `pyglet`! – Klaus D. Jun 03 '22 at 09:43
  • Arcade 2.6.15 was released to resolve this – Grimmy Jun 03 '22 at 18:49

2 Answers2

0

This is a known bug in the pyglet library: https://github.com/pyglet/pyglet/issues/614

The code uses list[Controller] which requires Python 3.9 (see PEP 585).

The line was introduced to pyglet in commit 3c2c7de and was fixed in commit 63341c4 (10 days ago as of today), which changes it to List[Controller] (where List is imported from the standard typing module).

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
0

Based on the response from @mkrieger1, and the error being shown, I took the following steps:

vim /home/brian/.local/lib/python3.8/site-packages/pyglet/input/evdev.py

added a line below the other import sections at the top

import typing

then went to line 583 (now 584 due to adding above), and changed

def get_controllers(self) -> list[Controller]:

to

def get_controllers(self) -> typing.List[Controller]:

and the example programs are now working.

If anyone else is in the same situation, then hopefully this is a quick fix to try.

Brian
  • 101
  • 1