Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Can't install MLAGENTS

Discussion in 'ML-Agents' started by tntisthebomb, Apr 28, 2023.

  1. tntisthebomb

    tntisthebomb

    Joined:
    Oct 14, 2021
    Posts:
    2
    I've done pretty much everything that the internet says to fix these errors after pip3 installing the mlagents package, It tells me that everything was already met (requirement wise) but Then hands me this error after running mlagents-learn --help. I used most python versions and am using 3.9.12 currently, Here's the error:

    Requirement already satisfied: mlagents in c:\users\user\anaconda3\lib\site-packages (0.28.0)
    Requirement already satisfied: grpcio>=1.11.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.54.0)
    Requirement already satisfied: h5py>=2.9.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (3.7.0)
    Requirement already satisfied: mlagents-envs==0.28.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (0.28.0)
    Requirement already satisfied: numpy<2.0,>=1.13.3 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.23.5)
    Requirement already satisfied: Pillow>=4.2.1 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (9.4.0)
    Requirement already satisfied: protobuf>=3.6 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (3.20.0)
    Requirement already satisfied: pyyaml>=3.1.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (6.0)
    Requirement already satisfied: tensorboard>=1.15 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (2.12.2)
    Requirement already satisfied: attrs>=19.3.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (22.1.0)
    Requirement already satisfied: pypiwin32==223 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (223)
    Requirement already satisfied: cattrs<1.7,>=1.1.0 in c:\users\user\anaconda3\lib\site-packages (from mlagents) (1.5.0)
    Requirement already satisfied: cloudpickle in c:\users\user\anaconda3\lib\site-packages (from mlagents-envs==0.28.0->mlagents) (2.0.0)
    Requirement already satisfied: pywin32>=223 in c:\users\user\anaconda3\lib\site-packages (from pypiwin32==223->mlagents) (305.1)
    Requirement already satisfied: absl-py>=0.4 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.4.0)
    Requirement already satisfied: google-auth<3,>=1.6.3 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.17.3)
    Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.0.0)
    Requirement already satisfied: markdown>=2.6.8 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (3.4.1)
    Requirement already satisfied: requests<3,>=2.21.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.28.1)
    Requirement already satisfied: setuptools>=41.0.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (65.6.3)
    Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (0.7.0)
    Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (1.8.1)
    Requirement already satisfied: werkzeug>=1.0.1 in c:\users\user\anaconda3\lib\site-packages (from tensorboard>=1.15->mlagents) (2.2.2)
    Requirement already satisfied: wheel>=0.26 in c:\users\user\appdata\roaming\python\python310\site-packages (from tensorboard>=1.15->mlagents) (0.37.1)
    Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (5.3.0)
    Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (0.2.8)
    Requirement already satisfied: six>=1.9.0 in c:\users\user\appdata\roaming\python\python310\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (1.16.0)
    Requirement already satisfied: rsa<5,>=3.1.4 in c:\users\user\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (4.9)
    Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\user\anaconda3\lib\site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard>=1.15->mlagents) (1.3.1)
    Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (2.0.4)
    Requirement already satisfied: idna<4,>=2.5 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (3.4)
    Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (1.26.14)
    Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents) (2022.12.7)
    Requirement already satisfied: MarkupSafe>=2.1.1 in c:\users\user\anaconda3\lib\site-packages (from werkzeug>=1.0.1->tensorboard>=1.15->mlagents) (2.1.1)
    Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\users\user\anaconda3\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents) (0.4.8)
    Requirement already satisfied: oauthlib>=3.0.0 in c:\users\user\anaconda3\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard>=1.15->mlagents) (3.2.2)
    C:\Users\User>mlagents-learn --help
    Traceback (most recent call last):
    File "C:\Users\User\anaconda3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "C:\Users\User\anaconda3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
    File "C:\Users\User\anaconda3\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module>
    File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\learn.py", line 2, in <module>
    from mlagents import torch_utils
    File "C:\Users\User\anaconda3\lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch # noqa
    File "C:\Users\User\anaconda3\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
    File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\settings.py", line 644, in <module>
    class TrainerSettings(ExportableSettings):
    File "C:\Users\User\anaconda3\lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings
    cattr.register_structure_hook(
    File "C:\Users\User\anaconda3\lib\site-packages\cattr\converters.py", line 207, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
    File "C:\Users\User\anaconda3\lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list
    self._single_dispatch.register(cls, handler)
    File "C:\Users\User\anaconda3\lib\functools.py", line 856, in register
    raise TypeError(
    TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class.
     
  2. aabduljawad

    aabduljawad

    Joined:
    Apr 1, 2023
    Posts:
    16
    Can you confirm what version of PyTorch are you using? If you have anything other than 1.7.1 I would recommend removing it and reinstalling 1.7.1 as this is the version recommended in the installation guide.
    To be honest, installing ML-Agents is way more a hassle than it should be, and it's very picky about what version of Python and PyTorch it can work with, I hope the developers fix this.
     
  3. tntisthebomb

    tntisthebomb

    Joined:
    Oct 14, 2021
    Posts:
    2
    So the issue was because I wasn't using the exact version of python that it needed
    Thank you for the help though :(
     
  4. hibbygames

    hibbygames

    Joined:
    Mar 19, 2015
    Posts:
    50
    Which is the correct version of python? I wish there was a list somewhere that was frequently updated with the current version of each thing to install so that everything is compatible.
     
    Claytonious likes this.
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    908
    It's a fragile, cobbled together mess of 3rd party tools that are in constant flux. I don't think the MLAgents authors are even able to tell you exactly what versions of everything you need at any given point in time on any given machine.

    I particularly hate this Python dependency across the OS's we work on with our Unity projects.
     
    hibbygames likes this.
  6. hibbygames

    hibbygames

    Joined:
    Mar 19, 2015
    Posts:
    50
    Haha, damn it! It's so frustrating because I'm really exciting to train some ai behaviours. I've watched tutorials and have a good idea how to design the training, just can't get the stupid Python side installed properly.
     
  7. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    186
    I had the same problems:
    How it worked for me was to install it from disk, with mlagents "advanced" way.

    Mlagents 20
    Python 3.8.16

    one bug was to downgrade one package, dot remember which, after that it worked.
    I also head to manually install Onix NN files, really easy too. Just follow the error events

    Hope this helps you, Cheers!
     
  8. AmineUM6P

    AmineUM6P

    Joined:
    Aug 8, 2023
    Posts:
    4