ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

mlagents-learn command fails after install

Open jwrl7 opened this issue 2 years ago • 7 comments

Describe the bug* A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

$pip3 install mlagents==0.28.0
$mlagents-learn --help # or any other command with mlagents-learn

Console logs / stack traces Please wrap in triple backticks (```) to make it easier to read.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Unity Version: [e.g. Unity 2020.3.25f]
  • OS + version: [e.g. Ubuntu 20.04]
  • ML-Agents version: (e.g. ML-Agents release_19)
  • Torch version: (Version: 1.8.2+cu111)
  • Environment: (none - can not run mlagents-learn --help )

NOTE: We are unable to help reproduce bugs with custom environments. Please attempt to reproduce your issue with one of the example environments, or provide a minimal patch to one of the environments needed to reproduce the issue

Follow the instructions to install dependencies, mlagents-learn command fails to run:

ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ mlagents-learn --help
Traceback (most recent call last):
  File "/home/ghj/.local/bin/mlagents-learn", line 5, in <module>
    from mlagents.trainers.learn import main
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/torch_utils/__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/torch_utils/torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/trainers/settings.py", line 5, in <module>
    import cattr
  File "/home/ghj/.local/lib/python3.8/site-packages/cattr/__init__.py", line 1, in <module>
    from .converters import Converter, GenConverter, UnstructureStrategy
  File "/home/ghj/.local/lib/python3.8/site-packages/cattr/converters.py", line 13, in <module>
    from attr import resolve_types, has as attrs_has
ImportError: cannot import name 'resolve_types' from 'attr' (/usr/lib/python3/dist-packages/attr/__init__.py)

Below is the full history of installing.

ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ pip3 install torch==1.8.2 torchvision==0.9.2 torchaudio==0.8.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu111
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/lts/1.8/cu111
Collecting torch==1.8.2
  Downloading https://download.pytorch.org/whl/lts/1.8/cu111/torch-1.8.2%2Bcu111-cp38-cp38-linux_x86_64.whl (1982.2 MB)
     |████████████████████████████████| 1982.2 MB 6.4 kB/s 
Collecting torchvision==0.9.2
  Downloading https://download.pytorch.org/whl/lts/1.8/cu111/torchvision-0.9.2%2Bcu111-cp38-cp38-linux_x86_64.whl (17.5 MB)
     |████████████████████████████████| 17.5 MB 5.2 MB/s 
Collecting torchaudio==0.8.2
  Downloading https://download.pytorch.org/whl/lts/1.8/torchaudio-0.8.2-cp38-cp38-linux_x86_64.whl (1.9 MB)
     |████████████████████████████████| 1.9 MB 8.4 MB/s 
Requirement already satisfied: typing-extensions in /home/ghj/.local/lib/python3.8/site-packages (from torch==1.8.2) (4.2.0)
Requirement already satisfied: numpy in /home/ghj/.local/lib/python3.8/site-packages (from torch==1.8.2) (1.22.3)
Requirement already satisfied: pillow>=4.1.1 in /home/ghj/.local/lib/python3.8/site-packages (from torchvision==0.9.2) (9.1.0)
Installing collected packages: torch, torchvision, torchaudio
  Attempting uninstall: torchvision
    Found existing installation: torchvision 0.12.0
    Uninstalling torchvision-0.12.0:
      Successfully uninstalled torchvision-0.12.0
Successfully installed torch-1.8.2+cu111 torchaudio-0.8.2 torchvision-0.9.2+cu111
ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ pip3 install mlagents=0.28.0
ERROR: Invalid requirement: 'mlagents=0.28.0'
Hint: = is not a valid operator. Did you mean == ?
ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ pip3 install mlagents==0.28.0
Collecting mlagents==0.28.0
  Using cached mlagents-0.28.0-py3-none-any.whl (164 kB)
Requirement already satisfied: pyyaml>=3.1.0 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (6.0)
Requirement already satisfied: numpy<2.0,>=1.13.3 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (1.22.3)
Requirement already satisfied: torch<1.9.0,>=1.6.0; platform_system != "Windows" and python_version < "3.9" in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (1.8.2+cu111)
Requirement already satisfied: grpcio>=1.11.0 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (1.44.0)
Requirement already satisfied: mlagents-envs==0.28.0 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (0.28.0)
Requirement already satisfied: tensorboard>=1.15 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (2.9.1)
Requirement already satisfied: attrs>=19.3.0 in /usr/lib/python3/dist-packages (from mlagents==0.28.0) (19.3.0)
Requirement already satisfied: cattrs<1.7,>=1.1.0; python_version >= "3.8" in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (1.5.0)
Requirement already satisfied: Pillow>=4.2.1 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (9.1.0)
Requirement already satisfied: protobuf>=3.6 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (3.19.4)
Requirement already satisfied: h5py>=2.9.0 in /home/ghj/.local/lib/python3.8/site-packages (from mlagents==0.28.0) (3.7.0)
Requirement already satisfied: typing-extensions in /home/ghj/.local/lib/python3.8/site-packages (from torch<1.9.0,>=1.6.0; platform_system != "Windows" and python_version < "3.9"->mlagents==0.28.0) (4.2.0)
Requirement already satisfied: six>=1.5.2 in /usr/lib/python3/dist-packages (from grpcio>=1.11.0->mlagents==0.28.0) (1.14.0)
Requirement already satisfied: cloudpickle in /home/ghj/.local/lib/python3.8/site-packages (from mlagents-envs==0.28.0->mlagents==0.28.0) (2.1.0)
Requirement already satisfied: requests<3,>=2.21.0 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (2.27.1)
Requirement already satisfied: wheel>=0.26 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (0.37.1)
Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (0.6.1)
Requirement already satisfied: absl-py>=0.4 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (1.0.0)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (1.8.1)
Requirement already satisfied: markdown>=2.6.8 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (3.3.6)
Requirement already satisfied: google-auth<3,>=1.6.3 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (2.6.6)
Requirement already satisfied: werkzeug>=1.0.1 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (2.1.1)
Requirement already satisfied: setuptools>=41.0.0 in /usr/lib/python3/dist-packages (from tensorboard>=1.15->mlagents==0.28.0) (45.2.0)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /home/ghj/.local/lib/python3.8/site-packages (from tensorboard>=1.15->mlagents==0.28.0) (0.4.6)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents==0.28.0) (1.25.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents==0.28.0) (2019.11.28)
Requirement already satisfied: idna<4,>=2.5; python_version >= "3" in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents==0.28.0) (2.8)
Requirement already satisfied: charset-normalizer~=2.0.0; python_version >= "3" in /home/ghj/.local/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard>=1.15->mlagents==0.28.0) (2.0.12)
Requirement already satisfied: importlib-metadata>=4.4; python_version < "3.10" in /home/ghj/.local/lib/python3.8/site-packages (from markdown>=2.6.8->tensorboard>=1.15->mlagents==0.28.0) (4.11.3)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in /home/ghj/.local/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents==0.28.0) (5.0.0)
Requirement already satisfied: rsa<5,>=3.1.4; python_version >= "3.6" in /home/ghj/.local/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents==0.28.0) (4.8)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/lib/python3/dist-packages (from google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents==0.28.0) (0.2.1)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /home/ghj/.local/lib/python3.8/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=1.15->mlagents==0.28.0) (1.3.1)
Requirement already satisfied: zipp>=0.5 in /usr/lib/python3/dist-packages (from importlib-metadata>=4.4; python_version < "3.10"->markdown>=2.6.8->tensorboard>=1.15->mlagents==0.28.0) (1.0.0)
Requirement already satisfied: pyasn1>=0.1.3 in /usr/lib/python3/dist-packages (from rsa<5,>=3.1.4; python_version >= "3.6"->google-auth<3,>=1.6.3->tensorboard>=1.15->mlagents==0.28.0) (0.4.2)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/lib/python3/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard>=1.15->mlagents==0.28.0) (3.1.0)
Installing collected packages: mlagents
Successfully installed mlagents-0.28.0
ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ mlagents-learn --help
Traceback (most recent call last):
  File "/home/ghj/.local/bin/mlagents-learn", line 5, in <module>
    from mlagents.trainers.learn import main
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/torch_utils/__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/torch_utils/torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "/home/ghj/.local/lib/python3.8/site-packages/mlagents/trainers/settings.py", line 5, in <module>
    import cattr
  File "/home/ghj/.local/lib/python3.8/site-packages/cattr/__init__.py", line 1, in <module>
    from .converters import Converter, GenConverter, UnstructureStrategy
  File "/home/ghj/.local/lib/python3.8/site-packages/cattr/converters.py", line 13, in <module>
    from attr import resolve_types, has as attrs_has
ImportError: cannot import name 'resolve_types' from 'attr' (/usr/lib/python3/dist-packages/attr/__init__.py)
Oryx-Pro:~/Unity/ml-agents/ml-agents$ git branch 
* (HEAD detached at release_19)
  main
Oryx-Pro:~/Unity/ml-agents/ml-agents$ pip3 show torch
Name: torch
Version: 1.8.2+cu111
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: [email protected]
License: BSD-3
Location: /home/ghj/.local/lib/python3.8/site-packages
Requires: typing-extensions, numpy
Required-by: torchvision, torchaudio, thop, mlagents
ghj@Oryx-Pro:~/Unity/ml-agents/ml-agent$ 
ghj@Oryx-Pro:~/Unity/ml-agents/ml-agents$ python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 



jwrl7 avatar Jun 16 '22 14:06 jwrl7

I've reproduced the environment you describe but do not get the error you are getting. Can you do a pip3 list and share it?

jrupert-unity avatar Jun 21 '22 17:06 jrupert-unity

pip3_list.txt

^^ Here you go good sir.

jwrl7 avatar Jun 26 '22 07:06 jwrl7

This issue has been automatically marked as stale because it has not had activity in the last 28 days. It will be closed in the next 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 03:07 stale[bot]

Currently getting the same issue:

~/44797/Documents/unityModels   unity 3.7.0 master ❯ mlagents-learn --help                                                         16:58:42
Traceback (most recent call last):
  File "/home/laurie/.local/bin/mlagents-learn", line 5, in <module>
    from mlagents.trainers.learn import main
  File "/home/laurie/.local/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "/home/laurie/.local/lib/python3.8/site-packages/mlagents/torch_utils/__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
  File "/home/laurie/.local/lib/python3.8/site-packages/mlagents/torch_utils/torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "/home/laurie/.local/lib/python3.8/site-packages/mlagents/trainers/settings.py", line 5, in <module>
    import cattr
  File "/home/laurie/.local/lib/python3.8/site-packages/cattr/__init__.py", line 1, in <module>
    from .converters import Converter, GenConverter, UnstructureStrategy
  File "/home/laurie/.local/lib/python3.8/site-packages/cattr/converters.py", line 13, in <module>
    from attr import resolve_types, has as attrs_has
ImportError: cannot import name 'resolve_types' from 'attr' (/usr/lib/python3/dist-packages/attr/__init__.py)

How did you solve?

lrfreeman avatar Sep 02 '22 16:09 lrfreeman

Same here. Is there any solution to this?

PcSpecific avatar Sep 19 '22 18:09 PcSpecific

What versions of attrs and cattrs do you have?

jrupert-unity avatar Sep 20 '22 18:09 jrupert-unity

I fixed by moving from installing on linux using WSL, to using windows for the install

On Tue, 20 Sep 2022, 19:46 Jason Rupert, @.***> wrote:

What versions of attrs and cattrs do you have?

— Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/ml-agents/issues/5755#issuecomment-1252769934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFLQW3U4ZL5I5ZUNEOFXOHTV7IA7XANCNFSM5Y67SHWA . You are receiving this because you commented.Message ID: @.***>

lrfreeman avatar Sep 20 '22 18:09 lrfreeman