I am trying to install mlagents. I got to the part in python but after creating a virtual enviorment with pyenv and setting the local version to 3.10, 3.9, and 3.8 it works on none of them. I upgraded pip, installed mlagents, then torch,torchvision, and torchaudio. Then I tested mlagents-learn --help and then because of a error installed protobuf 3.20.3. I then tested again to get the following error
(venv) D:\Unity\AI Ecosystem>mlagents-learn --help
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "D:\Unity\AI Ecosystem\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module>
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\learn.py", line 2, in <module>
from mlagents import torch_utils
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module>
from mlagents.torch_utils.torch import torch as torch # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\torch_utils\torch.py", line 6, in <module>
from mlagents.trainers.settings import TorchSettings
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\settings.py", line 644, in <module>
class TrainerSettings(ExportableSettings):
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings
cattr.register_structure_hook(
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\cattr\converters.py", line 207, in register_structure_hook
self._structure_func.register_cls_list([(cl, func)])
File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list
self._single_dispatch.register(cls, handler)
File "C:\Users\Ebrah\AppData\Local\Programs\Python\Python311\Lib\functools.py", line 864, in register
raise TypeError(
TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.
I tried installing cattrs 1.5.0 but the error remains. As I said before I also tried in 3.11, 3.10, 3.9 and 3.8 and got the same error in all of them. My unity version is 2022.3.5f1 but I don't see how that would make a difference. My pyenv version is 3.1.1. I am on windows 11 and am using pyenv-win.
Try deleting your unity project and making a new one. Unity says to use conda so try that too. Use python 3.9.