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

[Bug Report] Install gymnasium with atari games using conda #1258

Open
1 task done
TheophileChampion opened this issue Nov 20, 2024 · 4 comments
Open
1 task done

[Bug Report] Install gymnasium with atari games using conda #1258

TheophileChampion opened this issue Nov 20, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TheophileChampion
Copy link

TheophileChampion commented Nov 20, 2024

Describe the bug

When trying to install gymnasium with Atari games using conda, I get various error messages, for example:

  • No module named 'ale_py'
  • No such file or directory: '[...]/ale_py/roms/pong.bin'

Code example

My setup.py:

from setuptools import find_packages
from setuptools import setup

setup(
    name="benchmarks",
    version="0.0.0",
    ...
    packages=find_packages(),
    scripts=["scripts/run_training"],
    include_package_data=True,
    install_requires=[
        # "gymnasium==1.0.0",
        # or "gymnasium-atari==1.0.0",
        # or "gymnasium-all==1.0.0", 
        "pytorch==2.5.1",
        "pytorchrl==0.6.0",
    ],
    python_requires="~=3.11",
    ...
)

My code:

import gymnasium as gym
import ale_py

if __name__ == '__main__':
    gym.register_envs(ale_py)
    env = gym.make("ALE/Pong-v5")

When I import "gymnasium==1.0.0", I get the error:

ModuleNotFoundError: No module named 'ale_py'

When I import "gymnasium-atari==1.0.0", I get the error:

FileNotFoundError: [Errno 2] No such file or directory: '[...]/lib/python3.11/site-packages/ale_py/roms/pong.bin'

When I import "gymnasium-all==1.0.0", I get the error:

FileNotFoundError: [Errno 2] No such file or directory: '[...]/lib/python3.11/site-packages/ale_py/roms/pong.bin'

I have also tried to import "ale_py==0.10.1" but it seems to be a dependency of both previously mentioned packages, and did not change anything.

System info

Ubuntu 24.04.1 LTS
Gymnasium 1.0.0
Python 3.11
Conda 24.5.0

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo
@TheophileChampion TheophileChampion added the bug Something isn't working label Nov 20, 2024
@Nikhil-24-04
Copy link

import gymnasium as gym

if name == 'main':
env = gym.make("ALE/Pong-v5", render_mode="human")
observation, info = env.reset()

for _ in range(1000):
    env.render()
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        observation, info = env.reset()

env.close()

@TheophileChampion
Copy link
Author

Thanks for you answer, I have tried many things including this variation. Unfortunately, I still get the same errors.

Just to make it clear my problem is about using conda, more specifically setup.py to create a package.

For example, I am able to install gymnasium using pip and requirements.txt as follows:

gymnasium[atari, accept-rom-licesnse]==1.0.0
torch==2.5.1
torchrl==0.6.0
tensorboard==2.18.0

Then, the following code runs:

import gymnasium as gym
import ale_py


if __name__ == '__main__':
    env = gym.make("ALE/Pong-v5", render_mode="human")
    observation, info = env.reset()

    for _ in range(1000):
        env.render()
        action = env.action_space.sample()
        observation, reward, terminated, truncated, info = env.step(action)
        if terminated or truncated:
            observation, info = env.reset()

    env.close()

Note, import ale_py is actually useful as otherwise I get the following error:

Traceback (most recent call last):
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/scripts/run_training.py", line 25, in <module>
    env = gym.make("ALE/Pong-v5", render_mode="human")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/rl-bench-venv/lib/python3.12/site-packages/gymnasium/envs/registration.py", line 687, in make
    env_spec = _find_spec(id)
               ^^^^^^^^^^^^^^
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/rl-bench-venv/lib/python3.12/site-packages/gymnasium/envs/registration.py", line 531, in _find_spec
    _check_version_exists(ns, name, version)
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/rl-bench-venv/lib/python3.12/site-packages/gymnasium/envs/registration.py", line 397, in _check_version_exists
    _check_name_exists(ns, name)
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/rl-bench-venv/lib/python3.12/site-packages/gymnasium/envs/registration.py", line 360, in _check_name_exists
    _check_namespace_exists(ns)
  File "/home/theophile/Desktop/portfolio/ReinforcementLearningBenckmarks/rl-bench-venv/lib/python3.12/site-packages/gymnasium/envs/registration.py", line 354, in _check_namespace_exists
    raise error.NamespaceNotFound(f"Namespace {ns} not found. {suggestion_msg}")
gymnasium.error.NamespaceNotFound: Namespace ALE not found. Have you installed the proper package for ALE?

@pseudo-rnd-thoughts
Copy link
Member

Apologies, I thought this was fixed, I would use pip install ale-py if you using gymnasium>=1.0 as the conda package for ale-py is broken currently.
I'm working on a fix

@TheophileChampion
Copy link
Author

Sounds good, for now I am using the requirements.txt with pip and everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants