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

Move import moviepy such that __del__ doesn't raise AttributeErrors #553

Conversation

pseudo-rnd-thoughts
Copy link
Member

@pseudo-rnd-thoughts pseudo-rnd-thoughts commented Jun 12, 2023

To replicate the issue, install gymnasium but not moviepy

import gymnasium as gym

env = gym.make("CartPole-v1", render_mode="rgb_array")
env = gym.wrappers.RecordVideo(env, "videos")
env.reset()
for _ in range(100):
    env.step(env.action_space.sample())

env.close()
gymnasium.error.DependencyNotInstalled: moviepy is not installed, run `pip install moviepy`
Exception ignored in: <function VideoRecorder.__del__ at 0x7f68807770d0>
Traceback (most recent call last):
  File ".../Gymnasium/gymnasium/wrappers/monitoring/video_recorder.py", line 178, in __del__
    if not self._closed:
AttributeError: 'VideoRecorder' object has no attribute '_closed'

This is partially confusing as the issue is not with VideoRecorder but with _closed

This PR solves the issue by moving the variables or try except such that the variables exist if the import fails

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit d5b2779 into Farama-Foundation:main Jun 12, 2023
13 checks passed
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 this pull request may close these issues.

None yet

1 participant