Search Unity

Question mlagents Nothing is working (python)

Discussion in 'ML-Agents' started by Mauznemo, Jan 3, 2023.

  1. Mauznemo

    Mauznemo

    Joined:
    Jan 29, 2022
    Posts:
    1
    I tried installing everything needed, followed the docs.
    1. it says install python 3.7.2 or Higher. So I installed 3.10.9 (it was the lowest i could find).
    2. I tried installing PyTorch with "pip3 install torch~=1.7.1 -f https://download.pytorch.org/whl/torch_stable.html" than i got the first error[*1] it said there is now version 1.7 so I installed 1.11.0 (the lowest) this worked.
    3. than I used "pip install mlagents==0.30.0" how the docs said and got an error[*2] again so I installed 0.28.0 (the newest I could find) and it worked.
    4. than I tried "mlagents-learn --help" to check if everything works but it didn't I got an error[*3] again. And this time I have no idea how to fix it.
    Now I don't know what to do is this all just a buggy outdated mess or am I doing something wrong? I also have like 50 Errors in unity after Importing the example project but I think I can fix them.
    (Im using Win 11 and I also tried python 3.11)


    [*1]
    ERROR: Could not find a version that satisfies the requirement torch~=1.7.1 (from versions: 1.11.0, 1.11.0+cpu, 1.11.0+cu113, 1.11.0+cu115, 1.12.0, 1.12.0+cpu, 1.12.0+cu113, 1.12.0+cu116, 1.12.1, 1.12.1+cpu, 1.12.1+cu113, 1.12.1+cu116, 1.13.0, 1.13.0+cpu, 1.13.0+cu116, 1.13.0+cu117, 1.13.1, 1.13.1+cpu, 1.13.1+cu116, 1.13.1+cu117)
    ERROR: No matching distribution found for torch~=1.7.1



    [*2]
    ERROR: Ignored the following versions that require a different python version: 0.10.0.dev0 Requires-Python >=3.6,<3.7; 0.29.0 Requires-Python >=3.7.2,<3.10.0; 0.30.0 Requires-Python >=3.8.13,<=3.10.8; 0.5.0 Requires-Python >=3.6,<3.7; 0.6.0 Requires-Python >=3.6,<3.7; 0.7.0 Requires-Python >=3.6,<3.7; 0.8.0 Requires-Python >=3.6,<3.7; 0.8.1 Requires-Python >=3.6,<3.7; 0.8.2 Requires-Python >=3.6,<3.7; 0.9.0 Requires-Python >=3.6,<3.7; 0.9.1 Requires-Python >=3.6,<3.7; 0.9.2 Requires-Python >=3.6,<3.7; 0.9.3 Requires-Python >=3.6,<3.7
    ERROR: Could not find a version that satisfies the requirement mlagents==0.30.0 (from versions: 0.4.0, 0.10.0.dev1, 0.10.0, 0.10.1, 0.11.0.dev0, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.18.0, 0.18.1, 0.19.0, 0.20.0, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.24.0, 0.24.1, 0.25.0, 0.25.1, 0.26.0, 0.27.0, 0.28.0)
    ERROR: No matching distribution found for mlagents==0.30.0


    [*3]

    (venv) D:\Programme\Unity\AiCat>mlagents-learn --help
    Traceback (most recent call last):
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
    File "D:\Programme\Unity\AiCat\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module>
    File "D:\Programme\Unity\AiCat\venv\lib\site-packages\mlagents\trainers\learn.py", line 2, in <module>
    from mlagents import torch_utils
    File "D:\Programme\Unity\AiCat\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:\Programme\Unity\AiCat\venv\lib\site-packages\mlagents\torch_utils\torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
    File "D:\Programme\Unity\AiCat\venv\lib\site-packages\mlagents\trainers\settings.py", line 644, in <module>
    class TrainerSettings(ExportableSettings):
    File "D:\Programme\Unity\AiCat\venv\lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings
    cattr.register_structure_hook(
    File "D:\Programme\Unity\AiCat\venv\lib\site-packages\cattr\converters.py", line 207, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
    File "D:\Programme\Unity\AiCat\venv\lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list
    self._single_dispatch.register(cls, handler)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\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. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Per *2, you need python <=3.10.8. "0.30.0 Requires-Python >=3.8.13,<=3.10.8". 0.30.0 is the latest verson. Thats the one you want.
     
    Ham-Dongki likes this.
  3. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    114
    Can someone explain WHY? Is Python that bad that it causes breaking changes? Or is Unity the culprit?
     
  4. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
  5. thomasphifer

    thomasphifer

    Joined:
    Mar 26, 2016
    Posts:
    13
    I am trying to install ML Agents:
    python -m pip install ./ml-agents-envs

    When I try it with Python 3.9 I get:
    ERROR: Package 'mlagents-envs' requires a different Python: 3.9.18 not in '<=3.10.12,>=3.10.1'

    Ok so we need Python 3.10.

    When I try it with Python 3.10 as the instructions say I get:
    ERROR: Package 'mlagents-envs' requires a different Python: 3.10.13 not in '<=3.10.12,>=3.10.1'

    Ok so we need Python 3.10.12 specifically.

    When I try it with Python 3.10.12 I get:
    Building wheel for numpy (pyproject.toml) ... error
    error: subprocess-exited-with-error
    × Building wheel for numpy (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [287 lines of output]
    setup.py:63: RuntimeWarning: NumPy 1.21.2 may not yet support Python 3.10.
    warnings.warn(
     
  6. mehdikhfifi

    mehdikhfifi

    Joined:
    Nov 22, 2023
    Posts:
    1
    i have the exact same issue
     
    thomasphifer likes this.
  7. thomasphifer

    thomasphifer

    Joined:
    Mar 26, 2016
    Posts:
    13
    Bumping the required version of numpy in the ml-agents\ml-agents-envs\setup file to 1.23.1 seems to have worked:
    Before:
    install_requires=[
    "cloudpickle",
    "grpcio>=1.11.0,<=1.48.2",
    "Pillow>=4.2.1",
    "protobuf>=3.6,<3.20",
    "pyyaml>=3.1.0",
    "gym>=0.21.0",
    "pettingzoo==1.15.0",
    "numpy==1.21.2",
    "filelock>=3.4.0",
    ],
    After:
    install_requires=[
    "cloudpickle",
    "grpcio>=1.11.0,<=1.48.2",
    "Pillow>=4.2.1",
    "protobuf>=3.6,<3.20",
    "pyyaml>=3.1.0",
    "gym>=0.21.0",
    "pettingzoo==1.15.0",
    "numpy==1.23.1",
    "filelock>=3.4.0",
    ],
     
    Last edited: Dec 11, 2023
    techleadne likes this.
  8. seldemirov

    seldemirov

    Joined:
    Nov 6, 2018
    Posts:
    48


    In which file did you find these lines of code? I think I checked everything, but I couldn't find the configuration file
     
  9. thomasphifer

    thomasphifer

    Joined:
    Mar 26, 2016
    Posts:
    13
    In your mlagents repo find the ml-agents-envs folder and open the setup text file. There you can change the numpy version that will get installed when you run the mlagents installation command. Change the numpy version to 1.23.1
     
  10. dengriaznov

    dengriaznov

    Joined:
    Jan 22, 2020
    Posts:
    1
    I encountered the same problem when trying to install MLagents in Colab or Kaggle Notebook (where it is generally very difficult to change the Python version).
    The issue was resolved by adding an option to ignore Python version requirements:

    pip install --ignore-requires-python mlagents==1.0.0

    Maybe it will work with torch too