Alexander Schatzberg
Alexander Schatzberg

Reputation: 23

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.

'''

Upvotes: 1

Views: 5153

Answers (3)

silver takana
silver takana

Reputation: 186

Like seth said,

Python 3.9 is not compatible. Neither is Python 3.10.

So, you will need to install Python 3.7 or 3.8. You don't have to delete the old python version, just change the environment variable to use the newly installed python version. It's likely you won't find an MSI or EXE for installing it. If you do not want to build the installer yourself, you can download unofficial installers from https://github.com/adang1345/PythonWindows.

Then, just follow the usual installation.

python -m venv venv

venv/Scripts/activate

pip3 install torch torchvision torchaudio

pip install mlagents

mlagents-learn --help

if you ran into

TypeError: Descriptors cannot not be created directly.

run the command

pip install protobuf==3.20.*

to down grade the protobuf version. after that, run mlagents-learn --help.

hope this helps.

Upvotes: 2

seth
seth

Reputation: 313

As user19218911 mentions, Python 3.9 is not compatible. Neither is Python 3.10.

Install Python 3.8, create the virtual environment, and download the packages using that version of python.

py -3.8 -m venv venv

venv/Scripts/activate

python install torch

python install mlagents

mlagents-learn --help

Upvotes: 2

user19218911
user19218911

Reputation: 11

Python 3.9 is not compatible. No idea why.

Upvotes: 0

Related Questions