benelot / pybullet-gym

Open-source implementations of OpenAI Gym MuJoCo environments for use with the OpenAI Gym Reinforcement Learning Research Platform.
https://pybullet.org/
Other
814 stars 124 forks source link

pybullet-gym is incompatible with pybullet 2.6.0 #36

Closed harrybraviner closed 4 years ago

harrybraviner commented 4 years ago

Installing pybullet-gym as per instructions in the README fails on new conda environments due to incompatibility with pybullet 2.6.0. Attempting to create an env by

import gym, pybulletgym
env = gym.make('HumanoidPyBulletEnv-v0')

results in this error:

pybullet build time: Dec 18 2019 12:54:45
current_dir=/home/harry/anaconda3/envs/temp_test_2/lib/python3.6/site-packages/pybullet_envs/bullet
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-fe077ecabe6a> in <module>
----> 1 env = gym.make('HumanoidPyBulletEnv-v0')

~/anaconda3/envs/temp_test_2/lib/python3.6/site-packages/gym/envs/registration.py in make(id, **kwargs)
    154 
    155 def make(id, **kwargs):
--> 156     return registry.make(id, **kwargs)
    157 
    158 def spec(id):

~/anaconda3/envs/temp_test_2/lib/python3.6/site-packages/gym/envs/registration.py in make(self, path, **kwargs)
     99             logger.info('Making new env: %s', path)
    100         spec = self.spec(path)
--> 101         env = spec.make(**kwargs)
    102         # We used to have people override _reset/_step rather than
    103         # reset/step. Set _gym_disable_underscore_compat = True on

~/anaconda3/envs/temp_test_2/lib/python3.6/site-packages/gym/envs/registration.py in make(self, **kwargs)
     70             env = self.entry_point(**_kwargs)
     71         else:
---> 72             cls = load(self.entry_point)
     73             env = cls(**_kwargs)
     74 

~/anaconda3/envs/temp_test_2/lib/python3.6/site-packages/gym/envs/registration.py in load(name)
     15 def load(name):
     16     mod_name, attr_name = name.split(":")
---> 17     mod = importlib.import_module(mod_name)
     18     fn = getattr(mod, attr_name)
     19     return fn

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/__init__.py in import_module(name, package)
    124                 break
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 
    128 

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_)

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap.py in _load_unlocked(spec)

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)

~/anaconda3/envs/temp_test_2/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/coding/pybullet-gym/pybulletgym/envs/roboschool/envs/locomotion/humanoid_env.py in <module>
----> 1 from pybulletgym.envs.roboschool.envs.locomotion.walker_base_env import WalkerBaseBulletEnv
      2 from pybulletgym.envs.roboschool.robots.locomotors import Humanoid
      3 
      4 
      5 class HumanoidBulletEnv(WalkerBaseBulletEnv):

~/coding/pybullet-gym/pybulletgym/envs/roboschool/envs/locomotion/walker_base_env.py in <module>
----> 1 from pybulletgym.envs.roboschool.envs.env_bases import BaseBulletEnv
      2 from pybulletgym.envs.roboschool.scenes import StadiumScene
      3 import pybullet
      4 import numpy as np
      5 

~/coding/pybullet-gym/pybulletgym/envs/roboschool/envs/env_bases.py in <module>
      2 import numpy as np
      3 import pybullet
----> 4 from pybullet_envs.bullet import bullet_client
      5 
      6 from pkg_resources import parse_version

ImportError: cannot import name 'bullet_client'

After some experimentation I discovered that downgrading pybullet using

pip install pybullet==2.5.6

fixes the issue. In pybullet 2.6.0 the bullet_client.py file is indeed completely absent.

ycps commented 4 years ago

https://github.com/benelot/pybullet-gym/pull/35 seems to fix this.

benelot commented 4 years ago

Thanks for helping each other out!I am going to merge #35 asap since it seems to be just a minor refactoring on the pybullet side which made it break on my side. Cheers!

On Thu, Dec 19, 2019 at 8:50 AM Yuri notifications@github.com wrote:

35 https://github.com/benelot/pybullet-gym/pull/35

seems to fix this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benelot/pybullet-gym/issues/36?email_source=notifications&email_token=AAXXXK4REUEVRSSAHKR5KW3QZMRVHA5CNFSM4J4O3ZL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHIXXWY#issuecomment-567376859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXXXKZ3XC7XVYBC5GNZUCDQZMRVHANCNFSM4J4O3ZLQ .

benelot commented 4 years ago

I anyone has the time to check on his/her side if everything works again, I would be super happy.

svadams commented 4 years ago

I had the exact same issue about a week ago - just updated my install today and it now works for me. Thanks for the fix!

benelot commented 4 years ago

Thanks for confirming that this fixes the issue.

isacarnekvist commented 4 years ago

Seems to be a problem with this again.

pybullet build time: May 28 2020 11:47:36
current_dir=/Users/isacar/workspace/rl_target_norm/venv/lib/python3.7/site-packages/pybullet_envs/bullet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/isacar/workspace/rl_target_norm/gym/gym/envs/registration.py", line 145, in make
    return registry.make(id, **kwargs)
  File "/Users/isacar/workspace/rl_target_norm/gym/gym/envs/registration.py", line 90, in make
    env = spec.make(**kwargs)
  File "/Users/isacar/workspace/rl_target_norm/gym/gym/envs/registration.py", line 59, in make
    cls = load(self.entry_point)
  File "/Users/isacar/workspace/rl_target_norm/gym/gym/envs/registration.py", line 18, in load
    mod = importlib.import_module(mod_name)
  File "/Users/isacar/workspace/rl_target_norm/venv/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/isacar/workspace/rl_target_norm/pybullet-gym/pybulletgym/envs/mujoco/envs/pendulum/inverted_pendulum_env.py", line 1, in <module>
    from pybulletgym.envs.mujoco.envs.env_bases import BaseBulletEnv
  File "/Users/isacar/workspace/rl_target_norm/pybullet-gym/pybulletgym/envs/mujoco/envs/env_bases.py", line 4, in <module>
    from pybullet_envs.bullet import bullet_client
ImportError: cannot import name 'bullet_client' from 'pybullet_envs.bullet' (/Users/isacar/workspace/rl_target_norm/venv/lib/python3.7/site-packages/pybullet_envs/bullet/__init__.py)

Version of pybullet:

> pip uninstall pybullet
Found existing installation: pybullet 2.7.9

I installed pybullet==2.5.6 and then it worked.