Search Unity

Resolved cannot import name 'NoReturn' when training

Discussion in 'ML-Agents' started by tezcatlipoca7123, Jan 15, 2021.

  1. tezcatlipoca7123

    tezcatlipoca7123

    Joined:
    Sep 4, 2019
    Posts:
    5
    I'm following this tutorial: https://github.com/Unity-Technologi..._docs/docs/Learning-Environment-Create-New.md

    I'm currently at the step Training the Environment and I get an error when trying to pass the config file to mlagents-learn using the
    "mlagents-learn config/rollerball_config.yaml --run-id=RollerBall"
    command. Here is the error I get:
    File "c:\users\tezca\appdata\local\programs\python\python36\lib\site-packages\torch\_fx\proxy.py", line 7, in <module>
    from typing import Tuple, Dict, Optional, Iterable, NoReturn, Any, Union, Callable
    ImportError: cannot import name 'NoReturn'

    I'm confused because when I use python interactively from the same environment and I enter "from typing import NoReturn" I get no errors.
     
  2. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    According to this : https://github.com/psf/black/issues/1666
    It seems that "typing.NoReturn" was added only in Python in 3.6.2
    I think the version of torch you are using is incompatible with your Python version. I would recommend installing a newer Python version like 3.7
     
  3. tezcatlipoca7123

    tezcatlipoca7123

    Joined:
    Sep 4, 2019
    Posts:
    5
    When I was first doing the tutorial my python version was 3.6.2. I just tried 3.7 and 3.9 and got the same error. I'm very confused by this because when I run python in the terminal and enter "from typing import NoReturn" I don't get any errors, but the mlagents-learn command does give me an error.
     
  4. tezcatlipoca7123

    tezcatlipoca7123

    Joined:
    Sep 4, 2019
    Posts:
    5
    I resolved the error by reinstalling torch and mlagents. After I did this several other import errors emerged. I resolved them all by reinstalling the packages.

    I'm assuming that if you see the unity logo in your terminal and it says listening on port then your good to go.

    Thank you, vincent, for responding to my thread!
     
  5. tezcatlipoca7123

    tezcatlipoca7123

    Joined:
    Sep 4, 2019
    Posts:
    5
    Maybe I should post this in a new thread since it is a new topic, but I don't want to spam threads.

    When I press play on the unity scene I get an error that I'm not sure how to resolve:
    File "c:\programdata\anaconda3\envs\test\lib\site-packages\torch\serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
    FileNotFoundError: [Errno 2] No such file or directory: 'results\\RollerBall\\RollerBall\\checkpoint.pt'

    do I have to add a "checkpoint.pt" file somewhere?

    Edit:
    I found the file checkpoint.pt under Assets/ML-Agents/results/RollerBall/RollerBall. I'm guessing the double \\ is why it's not finding the file. How is the path being supplied to serialization.py? Maybe I can remove the extra slash. It could also not be finding the file because serialization.py and the results directory are in different locations.
     
    Last edited: Jan 15, 2021
  6. tezcatlipoca7123

    tezcatlipoca7123

    Joined:
    Sep 4, 2019
    Posts:
    5
    I tried running the scene a second time and this time there was no error. Every issue has been resolved.

    Sorry about posting about things that resolved them selves. It was just really frustrating because for a couple days I was unable to even duplicate the simplest tutorial.