'I'm getting this error when trying to run the mlagents-learn command. All the correct versions of the correct packages are installed in a venv

I'm trying to use this toolkit to get the hang of creating machine learning agents in simulations. It seemed like the easiest one out there, so I followed a tutorial from a channel called CodeMonkey. Does anyone know what is going wrong here? (https://www.youtube.com/watchv=zPFU30tbyKs&ab_channel=CodeMonkey).

'''

Traceback (most recent call last):
  File "/usr/local/bin/mlagents-learn", line 5, in <module>
    from mlagents.trainers.learn import main
  File "/usr/local/lib/python3.9/site-packages/mlagents/trainers/learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "/usr/local/lib/python3.9/site-packages/mlagents/torch_utils/__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
  File "/usr/local/lib/python3.9/site-packages/mlagents/torch_utils/torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "/usr/local/lib/python3.9/site-packages/mlagents/trainers/settings.py", line 644, in <module>
    class TrainerSettings(ExportableSettings):
  File "/usr/local/lib/python3.9/site-packages/mlagents/trainers/settings.py", line 667, in TrainerSettings
    cattr.register_structure_hook(
  File "/usr/local/lib/python3.9/site-packages/cattr/converters.py", line 207, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
  File "/usr/local/lib/python3.9/site-packages/cattr/dispatch.py", line 55, in register_cls_list
    self._single_dispatch.register(cls, handler)
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 855, in register
    raise TypeError(
TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class.

'''



Solution 1:[1]

Python 3.9 is not compatible. No idea why.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user19218911