Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to install custom environments #1818

Closed
pablovin opened this issue Feb 21, 2020 · 5 comments
Closed

Not able to install custom environments #1818

pablovin opened this issue Feb 21, 2020 · 5 comments

Comments

@pablovin
Copy link

Dear all,

I am having a problem when trying to use custom environments. I first tried to create mine and got the problem. Then I tried to use existing custom environments and got the same problem.

I am running python3 over a virtual environment.

I am using this as an example and as a reference for the error: https://github.com/nczempin/gym-tic-tac-toe

The custom environment installed without an error:

Installing collected packages: gym-tic-tac-toe
Running setup.py develop for gym-tic-tac-toe
Successfully installed gym-tic-tac-toe

but when I try to create it, I get the message it is not found:

gym.error.UnregisteredEnv: No registered env with id: tic_tac_toe-v1

Also running through the installed environments, I get nothing:

python3 -c "import gym; print(sorted([env.id for env in gym.envs.registry.all() if 'tictac' in env.id])); print(gym.file)"
[]
/home/pablo/Documents/VirtualEnv/EmotionRecognition/lib/python3.6/site-packages/gym/init.py

Would any of you have experienced this before? Does anyone have any idea of what the problem can be?

thanks in advance!

Pablo

@fkdosilovic
Copy link

I've had a similar problem (also on third-party environment) and solved it by following instructions from Issue 626 - How to make environment. Basically, the solution is to import the package where the environment is located. Do not forget to read the note at the end about PYTHONPATH!

@christopherhesse
Copy link
Contributor

You need to either import <name of your package> or do gym.make("<name of your package>:tic_tac_toe-v1"), see the creating environment guide for more information: https://github.com/openai/gym/blob/master/docs/creating-environments.md

@kncrane
Copy link

kncrane commented Mar 4, 2020

Hello,

I am getting the same error message and I don't understand what I am doing wrong as everything seems to be as described here, at #626 , and at creating-environments.md

I have a private github repo called gym-gridworld with the exact same structure and content as provided in creating-environments.md but with added code to gridworld_env.py to give implementations to def step, def reset etc.

From the terminal I cloned the repo into a project folder on my laptop, cd into project folder, pipenv shell into my virtual environment, cd into gym-gridworld, and called pip install e . which returned 'Successfully installed e-1.4.5 gym-gridworld-0.0.1' and gym_gridworld appears when I call pip list

From there (so still within gym-gridworld directory) I call python, import gym, and then env = gym.make('gym_gridworld:gridworld-v0') and get same error as @pablovin . The error is thrown from line 86 of python3.6/site-packages/gym/envs/registration.py (NB that this is the install of python 3.6 within my virtualenv) which is spec = self.spec(path). Adding import gym_gridworld doesn't help.

I'm on Linux Ubuntu
Python 3.6.9
gym == 0.16.0

Any idea what is amiss? Thanks,
Kirsten

@kncrane
Copy link

kncrane commented Mar 4, 2020

Just to give more info, when I'm within the gym-gridworld directory and call import gym_gridworld it doesn't complain but then when I call gym.make I get ..

Traceback (most recent call last):
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 118, in spec
    return self.env_specs[id]
KeyError: 'gridworld-v0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 142, in make
    return registry.make(id, **kwargs)
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 86, in make
    spec = self.spec(path)
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 128, in spec
    raise error.UnregisteredEnv('No registered env with id: {}'.format(id))
gym.error.UnregisteredEnv: No registered env with id: gridworld-v0

However when I cd .. up a level to my project directory (the parent directory of gym-gridworld), trying to import gym_gridworld returns ...

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gym_gridworld'

and the gym.make error is slightly different ...

Traceback (most recent call last):
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 106, in spec
    importlib.import_module(mod_name)
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gym_gridworld'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 142, in make
    return registry.make(id, **kwargs)
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 86, in make
    spec = self.spec(path)
  File "/home/campus.ncl.ac.uk/b3024896/.local/share/virtualenvs/stable_baselines-ocA6ek_u/lib/python3.6/site-packages/gym/envs/registration.py", line 109, in spec
    raise error.Error('A module ({}) was specified for the environment but was not found, make sure the package is installed with `pip install` before calling `gym.make()`'.format(mod_name))
gym.error.Error: A module (gym_gridworld) was specified for the environment but was not found, make sure the package is installed with `pip install` before calling `gym.make()`

@kncrane
Copy link

kncrane commented Mar 5, 2020

Doesn't matter my two init.py files had single underscores instead of double so they weren't even running. No words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants