openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.53k stars 8.59k forks source link

Additional step to register an environment in python 3.4 (wrt 2.7) ? #308

Closed osigaud closed 8 years ago

osigaud commented 8 years ago

Hi,

I submitted a PR on a continuous mountain car environment. It goes through the integration test engine for python 2.7 For python 3.4, I get: "ERROR: InvocationError: '/usr/local/gym/.tox/py34/bin/nose2'

I don't know what it means.

Furthermore, when installing gym with python 3 (pip3 install -e . in .../gym) and running python3 my_program.py, I get env = gym.make('MountainCarContinuous-v0') File "/usr/local/lib/python3.4/dist-packages/gym/envs/registration.py", line 88, in make spec = self.spec(id) File "/usr/local/lib/python3.4/dist-packages/gym/envs/registration.py", line 110, in spec raise error.UnregisteredEnv('No registered env with id: {}'.format(id))

And it happens that my continuous_mountain_car.py is not present in

/usr/local/lib/python3.4/dist-packages/gym/envs/

So I'm wondering: isn't there an additional step for registering in python 3.4?

ppaquette commented 8 years ago

InvocationError is caused by a segfault on another environment. It happens periodically. Don't worry about it.

For the second part, I'm able to run your env with python3.4 when I clone the repo. Could it be trying to load your env from the wrong gym (0.2.3 vs local version)?

osigaud commented 8 years ago

Thanks for the reply

InvocationError is caused by a segfault on another environment. It happens periodically. Don't worry about it.

Well, it prevents my PR for being accepted, so I'm still caring a little ;) Do you have a way to make it "go through" anyways?

For the second part, I'm able to run your env with python3.4 when I clone the repo.

Thanks!

Could it be trying to load your env from the wrong gym (0.2.3 vs local version)?

Any idea how (which command) I can make sure?

osigaud commented 8 years ago

To be more specific:

Help very welcome! Olivier

ppaquette commented 8 years ago

That's the output I get on my computer. I'm using virtualenv on Ubuntu 16.04.

philip@philip-Vostro-230:/www/ppaquette$ cd osigaud/

philip@philip-Vostro-230:/www/ppaquette/osigaud$ git clone https://github.com/osigaud/gym.git
Cloning into 'gym'...
remote: Counting objects: 3373, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 3373 (delta 17), reused 0 (delta 0), pack-reused 3339
Receiving objects: 100% (3373/3373), 805.73 KiB | 700.00 KiB/s, done.
Resolving deltas: 100% (2252/2252), done.
Checking connectivity... done.

philip@philip-Vostro-230:/www/ppaquette/osigaud$ cd gym/

philip@philip-Vostro-230:/www/ppaquette/osigaud/gym$ virtualenv -p python3.4 .env3.4
Running virtualenv with interpreter /usr/bin/python3.4
Using base prefix '/usr'
New python executable in /www/ppaquette/osigaud/gym/.env3.4/bin/python3.4
Also creating executable in /www/ppaquette/osigaud/gym/.env3.4/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

philip@philip-Vostro-230:/www/ppaquette/osigaud/gym$ source .env3.4/bin/activate

(.env3.4) philip@philip-Vostro-230:/www/ppaquette/osigaud/gym$ pip3 install -e .
Obtaining file:///www/ppaquette/osigaud/gym
Collecting numpy>=1.10.4 (from gym==0.2.3)
  Using cached numpy-1.11.1-cp34-cp34m-manylinux1_x86_64.whl
Collecting requests>=2.0 (from gym==0.2.3)
  Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting six (from gym==0.2.3)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pyglet>=1.2.0 (from gym==0.2.3)
  Using cached pyglet-1.2.4-py3-none-any.whl
Installing collected packages: numpy, requests, six, pyglet, gym
  Running setup.py develop for gym
Successfully installed gym numpy-1.11.1 pyglet-1.2.4 requests-2.11.1 six-1.10.0

(.env3.4) philip@philip-Vostro-230:/www/ppaquette/osigaud/gym$ python3.4
Python 3.4.5 (default, Jul 15 2016, 16:39:07) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym
>>> env = gym.make('MountainCarContinuous-v0')
[2016-08-24 08:04:07,268] Making new env: MountainCarContinuous-v0
>>> env.reset()
array([-0.49473416,  0.        ])
>>> exit()
osigaud commented 8 years ago

Thanks.

Here is what I get: sudo pip3 install -e . --upgrade Obtaining file:///home/sigaud/Bureau/sigaud/DDPG_gym/DDPG/gym Running setup.py (path:/home/sigaud/Bureau/sigaud/DDPG_gym/DDPG/gym/setup.py) egg_info for package from file:///home/sigaud/Bureau/sigaud/DDPG_gym/DDPG/gym

Requirement already up-to-date: numpy>=1.10.4 in /usr/local/lib/python3.4/dist-packages (from gym==0.2.3) Requirement already up-to-date: requests>=2.0 in /usr/local/lib/python3.4/dist-packages (from gym==0.2.3) Requirement already up-to-date: six in /usr/local/lib/python3.4/dist-packages (from gym==0.2.3) Requirement already up-to-date: pyglet>=1.2.0 in /usr/local/lib/python3.4/dist-packages (from gym==0.2.3) Installing collected packages: gym Running setup.py develop for gym

Creating /usr/local/lib/python3.4/dist-packages/gym.egg-link (link to .)
gym 0.2.3 is already the active version in easy-install.pth

Installed /home/sigaud/Bureau/sigaud/DDPG_gym/DDPG/gym

Successfully installed gym Cleaning up...

then:

sigaud@ISIR2013136:~/Bureau/sigaud/DDPG_gym/DDPG/gym$ cd ../test sigaud@ISIR2013136:~/Bureau/sigaud/DDPG_gym/DDPG/test$ python3 test_mc_gym.py [2016-08-24 15:01:07,715] Making new env: MountainCarContinuous-v0 Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/gym/envs/registration.py", line 100, in spec return self.env_specs[id] KeyError: 'MountainCarContinuous-v0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "test_mc_gym.py", line 15, in env = gym.make('MountainCarContinuous-v0') File "/usr/local/lib/python3.4/dist-packages/gym/envs/registration.py", line 88, in make spec = self.spec(id) File "/usr/local/lib/python3.4/dist-packages/gym/envs/registration.py", line 110, in spec raise error.UnregisteredEnv('No registered env with id: {}'.format(id)) gym.error.UnregisteredEnv: No registered env with id: MountainCarContinuous-v0

I don't know what to do...

ppaquette commented 8 years ago

Can you paste the output of:

python3 -c "import gym; print(sorted([env.id for env in gym.envs.registry.all() if 'MountainCar' in env.id])); print(gym.__file__)"

and (with sudo)

sudo python3 -c "import gym; print(sorted([env.id for env in gym.envs.registry.all() if 'MountainCar' in env.id])); print(gym.__file__)"
osigaud commented 8 years ago

I get the same thing with and without the sudo: ['MountainCar-v0'] /usr/local/lib/python3.4/dist-packages/gym/init.py

ppaquette commented 8 years ago

The correct answer should be:

['MountainCar-v0', 'MountainCarContinuous-v0']
/home/sigaud/Bureau/sigaud/DDPG_gym/DDPG/gym__init__.py

Try deleting gym from /usr/local/lib/python3.4/dist-packages, and retry doing the pip3 install.

osigaud commented 8 years ago

Bug fixed! Thank you very much...

osigaud commented 8 years ago

Now remains the fact that my PR was rejected...

gdb commented 8 years ago

(Closing out this issue.)