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

[Proposal] Make pygame dependency optional for classic control #2691

Closed
1 task done
araffin opened this issue Mar 13, 2022 · 4 comments · Fixed by #2712
Closed
1 task done

[Proposal] Make pygame dependency optional for classic control #2691

araffin opened this issue Mar 13, 2022 · 4 comments · Fixed by #2712

Comments

@araffin
Copy link
Contributor

araffin commented Mar 13, 2022

Proposal

If I understand well, pygame is only used for rendering, so it should be possible to install gym and use classic control environments without installing pygame.

Motivation

Fewer dependencies are always nice.
Classic control envs are usually used to debug things/try things quickly without necessary the need to render them.
This would also prevent unexpected/inconsistent behavior, as in #2634 #2641 or #2642 (where previously a pip install gym would have sufficed).

Pitch

Make pygame dependency optional, throw an error if the user wants to render and pygame is not installed.

Alternatives

Do nothing.

Checklist

  • I have checked that there is no similar issue in the repo (required)

Tasks

No tasks being tracked yet.
@jkterry1
Copy link
Collaborator

But pygame already basically is an optional dependency for classic control? pip install gym installs all the code in gym, including the classic control envs. pip install gym[classic_control] only adds the pygame dependency.

See

gym/setup.py

Line 16 in 57b157b

"classic_control": ["pygame==2.1.0"],

@araffin
Copy link
Contributor Author

araffin commented Mar 14, 2022

But pygame already basically is an optional dependency for classic control?

# install gym 0.23.1
pip install git+https://github.com/openai/gym/@850247f888cc4642561488b7c17f8b29873b31bd
import gym

gym.make("Pendulum-v1")

yields ModuleNotFoundError: No module named 'pygame' as noted by other issues, hence you cannot use classic control env without pygame, even when you don't want to render anything.

with gym 0.21:

pip install gym==0.21
import gym

gym.make("Pendulum-v1")

does not throw any error and you can use the env without rendering anything.

@RedTachyon
Copy link
Contributor

Yea, this absolutely makes sense. It should be enough to just move the pygame imports into the body of render

@jkterry1
Copy link
Collaborator

Closing in favor of #2712

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

Successfully merging a pull request may close this issue.

3 participants