0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

gym.render() でpygame is not installed ~ のエラーが出たときの対処法

Last updated at Posted at 2022-08-14

困ったこと

Open AI Gym のenv.render() でエラーが発生してrender が使用できなくなった!というときに試す設定を書き残しておきます。

pygame is not installed ~ というエラーになる

使用したコードは下記の通りです。

import gym

env = gym.make('CartPole-v0')
observation = env.reset()
for i in range(100):
  env.render()
  observation, reward, done, info = env.step(1)
env.env.close()

下記のようにpygame is not installed ~ のようなエラーになる場合、

  File "/opt/anaconda3/envs/xxxx.py", line 199, in render
    raise DependencyNotInstalled(
gym.error.DependencyNotInstalled: pygame is not installed, run `pip install gym[classic_control]`

ターミナルで下記を追加してみましょう。

pip3 install pygame

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?