skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. 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).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search