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

ModuleNotFoundError: No module named 'baselines' #227

Open
amrzv opened this issue Jan 19, 2025 · 6 comments
Open

ModuleNotFoundError: No module named 'baselines' #227

amrzv opened this issue Jan 19, 2025 · 6 comments

Comments

@amrzv
Copy link

amrzv commented Jan 19, 2025

Hello.
When running jax_agent_visualizer.ipynb notebook in colab this error is raised on from dopamine.discrete_domains import atari_lib

ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-2-c78a96aa2548>](https://localhost:8080/#) in <cell line: 0>()
      1 # @title Imports
----> 2 from dopamine.discrete_domains import atari_lib
      3 from dopamine.jax.agents.dqn import dqn_agent
      4 from dopamine.jax.agents.implicit_quantile import implicit_quantile_agent
      5 from dopamine.jax.agents.quantile import quantile_agent

[/usr/local/lib/python3.11/dist-packages/dopamine/discrete_domains/atari_lib.py](https://localhost:8080/#) in <module>
     43 
     44 import ale_py
---> 45 from baselines.common import atari_wrappers
     46 import cv2
     47 import gin

ModuleNotFoundError: No module named 'baselines'

Image

@krtimisra67
Copy link

pip install baseline
(It might not be installed in your system)

@amrzv
Copy link
Author

amrzv commented Feb 4, 2025

Should it be in the requirements of this project then?

Btw, pip install baselines doesn't work in colab

Collecting baselines
  Using cached baselines-0.1.5.tar.gz (123 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: gym[atari,classic_control,mujoco,robotics] in /usr/local/lib/python3.11/dist-packages (from baselines) (0.25.2)
Requirement already satisfied: scipy in /usr/local/lib/python3.11/dist-packages (from baselines) (1.13.1)
Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (from baselines) (4.67.1)
Requirement already satisfied: joblib in /usr/local/lib/python3.11/dist-packages (from baselines) (1.4.2)
Collecting zmq (from baselines)
  Using cached zmq-0.0.0.zip (2.2 kB)
  Preparing metadata (setup.py) ... done
Collecting dill (from baselines)
  Using cached dill-0.3.9-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: progressbar2 in /usr/local/lib/python3.11/dist-packages (from baselines) (4.5.0)
Collecting mpi4py (from baselines)
  Using cached mpi4py-4.0.2.tar.gz (466 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cloudpickle in /usr/local/lib/python3.11/dist-packages (from baselines) (3.1.1)
Requirement already satisfied: tensorflow>=1.4.0 in /usr/local/lib/python3.11/dist-packages (from baselines) (2.18.0)
Requirement already satisfied: click in /usr/local/lib/python3.11/dist-packages (from baselines) (8.1.8)
Requirement already satisfied: absl-py>=1.0.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.4.0)
Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.6.3)
Requirement already satisfied: flatbuffers>=24.3.25 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (25.1.24)
Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (0.6.0)
Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (0.2.0)
Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (18.1.1)
Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (3.4.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (24.2)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.3 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (4.25.6)
Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (2.32.3)
Requirement already satisfied: setuptools in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (75.1.0)
Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.17.0)
Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (2.5.0)
Requirement already satisfied: typing-extensions>=3.6.6 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (4.12.2)
Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.17.2)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.70.0)
Requirement already satisfied: tensorboard<2.19,>=2.18 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (2.18.0)
Requirement already satisfied: keras>=3.5.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (3.8.0)
Requirement already satisfied: numpy<2.1.0,>=1.26.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (1.26.4)
Requirement already satisfied: h5py>=3.11.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (3.12.1)
Requirement already satisfied: ml-dtypes<0.5.0,>=0.4.0 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (0.4.1)
Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.11/dist-packages (from tensorflow>=1.4.0->baselines) (0.37.1)
WARNING: gym 0.25.2 does not provide the extra 'robotics'
Requirement already satisfied: gym_notices>=0.0.4 in /usr/local/lib/python3.11/dist-packages (from gym[atari,classic_control,mujoco,robotics]->baselines) (0.0.8)
INFO: pip is looking at multiple versions of gym[atari,classic-control,mujoco,robotics] to determine which version is compatible with other requirements. This could take a while.
Collecting gym[atari,classic_control,mujoco,robotics] (from baselines)
  Downloading gym-0.26.2.tar.gz (721 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 721.7/721.7 kB 15.3 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
WARNING: gym 0.26.2 does not provide the extra 'robotics'
Collecting ale-py~=0.8.0 (from gym[atari,classic_control,mujoco,robotics]->baselines)
  Downloading ale_py-0.8.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.1 kB)
Collecting pygame==2.1.0 (from gym[atari,classic_control,mujoco,robotics]->baselines)
  Downloading pygame-2.1.0.tar.gz (5.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.8/5.8 MB 71.5 MB/s eta 0:00:00
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Preparing metadata (setup.py) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.v

@krtimisra67
Copy link

Then try installing pygame before baselines
=> pip install pygame==2.1.0 --no-cache-dir
=> pip install pygame
=>pip install baselines
Also check for system dependencies
For Linux
=>sudo apt update
sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
For windows
=>python3 -m venv myenv
source myenv/bin/activate # On Windows, use "myenv\Scripts\activate"
pip install baselines

@amrzv
Copy link
Author

amrzv commented Feb 4, 2025

Looks like the problem is in outdated pypi package of baselines, see openai/baselines#693

I was able to install from source pip install git+https://github.com/openai/baselines. However, on from dopamine.replay_memory import circular_replay_buffer getting ModuleNotFoundError

ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-3-c78a96aa2548>](https://localhost:8080/#) in <cell line: 0>()
      5 from dopamine.jax.agents.quantile import quantile_agent
      6 from dopamine.jax.agents.rainbow import rainbow_agent
----> 7 from dopamine.replay_memory import circular_replay_buffer
      8 from dopamine.utils import example_viz_lib
      9 import gin

ModuleNotFoundError: No module named 'dopamine.replay_memory'

Image

@krtimisra67
Copy link

!pip install --upgrade --no-cache-dir git+https://github.com/google/dopamine.git # Reinstalling dopamine

Restart the runtime after this installation.

Try importing again:

from dopamine.replay_memory import circular_replay_buffer
print("Module imported successfully!")
[I tried on my system as well]

See i tried this but i think there is some issue with the file structure of the installed package or a conflict with other installed libraries.Double-check the output of !pip show dopamine to ensure it's installed and points to the correct location. You may need to examine the package structure to ensure replay_memory and circular_replay_buffer are present in the expected locations.

@amrzv
Copy link
Author

amrzv commented Feb 5, 2025

Installing both from souce

!pip install git+https://github.com/openai/baselines git+https://github.com/google/dopamine.git

fails
pythonpython
ERROR: Cannot install baselines, baselines==0.1.6, dopamine_rl and tensorflow-probability==0.24.0 because these package versions have conflicting dependencies.

The conflict is caused by:
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.24.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.25.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.23.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.22.1 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.22.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.21.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.20.1 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.19.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.18.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.17.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.16.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.15.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.14.1 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.14.0 depends on cloudpickle>=1.3
baselines 0.1.6 depends on cloudpickle
gym 0.15.4 depends on cloudpickle~=1.2.0
gymnasium 1.0.0 depends on cloudpickle>=1.2.0
tensorflow-probability 0.13.0 depends on cloudpickle>=1.3

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

2 participants