araffin / rl-baselines-zoo

A collection of 100+ pre-trained RL agents using Stable Baselines, training and hyperparameter optimization included.
https://stable-baselines.readthedocs.io/
MIT License
1.12k stars 208 forks source link

pybullet_envs required even for atari environments #39

Closed ClonedOne closed 4 years ago

ClonedOne commented 4 years ago

Describe the bug enjoy.py launches a ModuleNotFoundError: No module named 'pybullet_envs' even when operating only on atari environments.

Code example python enjoy.py --algo a2c --env BreakoutNoFrameskip-v4 --folder trained_agents/ -n 5000

System Info

➜ pip freeze
absl-py==0.8.0
astor==0.8.0
atari-py==0.2.6
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
cloudpickle==1.2.1
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
entrypoints==0.3
future==0.17.1
gast==0.2.2
google-pasta==0.1.7
grpcio==1.23.0
gym==0.14.0
h5py==2.9.0
ipykernel==5.1.2
ipython==7.8.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.15.1
Jinja2==2.10.1
joblib==0.13.2
jsonschema==3.0.2
jupyter==1.0.0
jupyter-client==5.3.1
jupyter-console==6.0.0
jupyter-core==4.5.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
kiwisolver==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.1
matplotlib==3.1.1
mistune==0.8.4
mpi4py==3.0.2
nbconvert==5.6.0
nbformat==4.4.0
notebook==6.0.1
numpy==1.16.4
opencv-python==4.1.0.25
pandas==0.25.1
pandocfilters==1.4.2
parso==0.5.1
pexpect==4.7.0
pickleshare==0.7.5
Pillow==6.1.0
prometheus-client==0.7.1
prompt-toolkit==2.0.9
protobuf==3.9.1
ptyprocess==0.6.0
pyglet==1.3.2
Pygments==2.4.2
pyparsing==2.4.2
pyrsistent==0.15.4
python-dateutil==2.8.0
pytz==2019.2
PyYAML==5.1.2
pyzmq==18.1.0
qtconsole==4.5.4
scikit-learn==0.21.3
scipy==1.3.1
Send2Trash==1.5.0
six==1.12.0
snakeviz==2.0.1
stable-baselines==2.7.0
tensorboard==1.14.0
tensorflow==1.14.0
tensorflow-estimator==1.14.0
termcolor==1.1.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.3
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.15.5
widgetsnbextension==3.5.1
wrapt==1.11.2

Additional context From the code of enjoy.py it seemed that the import of pybullet_envs is guarded, however the module raises the exception anyway.

# For pybullet envs
warnings.filterwarnings("ignore")
import gym
try:
    import pybullet_envs
except ImportError:
    pybullet_envs = None
import numpy as np
try:
    import highway_env
except ImportError:
    highway_env = None
import stable_baselines

The full trace of the exception is:

Traceback (most recent call last):
  File "enjoy.py", line 24, in <module>
    from utils import ALGOS, create_test_env, get_latest_run_id, get_saved_hyperparams
  File "/home/giorgio/projects/research/rl-baselines-zoo/utils/__init__.py", line 1, in <module>
    from .utils import make_env, ALGOS, linear_schedule, create_test_env,\
  File "/home/giorgio/projects/research/rl-baselines-zoo/utils/utils.py", line 9, in <module>
    import pybullet_envs
ModuleNotFoundError: No module named 'pybullet_envs'

So the problem is an unguarded import in rl-baselines-zoo/utils/utils.py

Easy fix would be to just wrap the import in the utils.py module, otherwise pybullet could be listed as a required dependency.

araffin commented 4 years ago

Hello, thanks for raising the issue, i would appreciate a pr with the proposed fix ;) (and pybullet is already present in the install instructions)

ClonedOne commented 4 years ago

Fair point, my bad, the dependency is stated in the instructions, I should have read them more carefully.

However, I don't really see any reason why it shouldn't be possible to run enjoy.py without pybullet for the other environments :) If you still think it may be useful I can send the pr.

araffin commented 4 years ago

yes, please do