lcswillems/rl-starter-files

Module 'torch_rl' has no attribute 'RecurrentACModel'

Closed this issue · 7 comments

When trying to run

(spinningup) Pablos-iMac:torch-rl pablo$ python3 -m scripts.train --algo ppo --env MiniGrid-DoorKey-5x5-v0

I get the following error

Traceback (most recent call last):
  File "/anaconda3/envs/spinningup/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/envs/spinningup/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/pablo/torch-rl/scripts/train.py", line 17, in <module>
    from model import ACModel
  File "/Users/pablo/torch-rl/model.py", line 17, in <module>
    class ACModel(nn.Module, torch_rl.RecurrentACModel):
AttributeError: module 'torch_rl' has no attribute 'RecurrentACModel'

I have not been able to find out what is going on.
Thanks!

Hi,
How did you install the package?
Did you do pip3 install -e torch_rl?

Hi,
Yes, I installed it that way. If I try running it again, I get that it uninstalls and reinstalls it.
Installing collected packages: torch-rl Found existing installation: torch-rl 1.0.0 Uninstalling torch-rl-1.0.0: Successfully uninstalled torch-rl-1.0.0 Running setup.py develop for torch-rl Successfully installed torch-rl

I can't reproduce your error...

I installed my package in a new environment and executed your command and I don't have any problem...

Did you modify some code in the repository?

I had not change anything. However, I've tried reinstalling "everything" from scratch. In particular, I've created a new environment
conda create -n spinningup python=3.7
Then

git clone https://github.com/openai/spinningup.git
cd spinningup
pip install -e .

Then I've installed the package inside spinningup directory

git clone https://github.com/lcswillems/torch-rl.git
cd torch-rl
pip3 install -e torch_rl

and inside torch_rl I've cloned and installed the Minigrid

git clone https://github.com/maximecb/gym-minigrid.git
cd gym-minigrid
pip3 install -e .

Finally, I've gone out of this last directory, so in the folder called torch-rl and executed
python3 -m scripts.train --algo ppo --env MiniGrid-DoorKey-5x5-v0 --model DoorKey
with the result you already know:

  File "/anaconda3/envs/spinningup/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/envs/spinningup/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/pablo/spinningup/torch-rl/scripts/train.py", line 17, in <module>
    from model import ACModel
  File "/Users/pablo/spinningup/torch-rl/model.py", line 17, in <module>
    class ACModel(nn.Module, torch_rl.RecurrentACModel):
AttributeError: module 'torch_rl' has no attribute 'RecurrentACModel'

I think it might have to do with the structure of directories... I'm unsure. However, if I am in a different directory and environment without the spinningup package, I get this:

Traceback (most recent call last):
  File "/anaconda3/envs/minigrid/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/envs/minigrid/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/pablo/torch-rl/scripts/train.py", line 4, in <module>
    import gym
ModuleNotFoundError: No module named 'gym'

I followed "exactly" what you did and I have no issue...

I write "exactly" between quotes because I replaced the "pip3" by "pip". I think that when you do "pip3", you install it for Python, not for your environment. This issue might come from this.

Let me know if it solves your problem.

Edit : And "python" instead of "python3"

I'm amazed. It was precisely that.
Many thanks!

Great!!
Good luck for your work :)