質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

2回答

2437閲覧

スタートアップシリーズ Pythonで学ぶ強化学習 [改訂第2版] 入門から実践まで:セットアップで躓きました

ttoo

総合スコア126

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/12/29 14:07

表題の書籍について
初めのセットアップに躓いてしましました

git clone https://github.com/icoxfog417/baby-steps-of-rl-ja.git pip install -r requirements.txt python welcome.py

最後にwelcome.pyを実行した結果下記のようなエラーが出力されました
こちらのエラーの原因について、教えていただきたいです。

LinuxAmazon Linux AMI release 2018.03
Python3.6になります。

エラー内容

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html couldn't import doomish Couldn't import doom ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4664:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2209:(snd_pcm_open_noupdate) Unknown PCM default ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name ALSA lib conf.c:4185:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4664:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2209:(snd_pcm_open_noupdate) Unknown PCM default /home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/gym/logger.py:30: UserWarning: WARN: Environment '<class 'gym_ple.ple_env.PLEEnv'>' has deprecated methods '_step' and '_reset' rather than 'step' and 'reset'. Compatibility code invoked. Set _gym_disable_underscore_compat = True to disable this behavior. warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow')) WARNING:tensorflow:From /home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/tensorflow/python/ops/init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor Traceback (most recent call last): File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 27, in <module> from pyglet.gl import * File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pyglet/gl/__init__.py", line 100, in <module> from pyglet.gl.lib import GLException File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pyglet/gl/lib.py", line 143, in <module> from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pyglet/gl/lib_glx.py", line 51, in <module> glu_lib = pyglet.lib.load_library('GLU') File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pyglet/lib.py", line 158, in load_library raise ImportError('Library "%s" not found.' % names[0]) ImportError: Library "GLU" not found. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "welcome.py", line 36, in <module> welcome() File "welcome.py", line 29, in welcome env.render(mode="human") File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/gym/envs/registration.py", line 176, in render return env._render(mode, close=False) File "/home/ec2-user/environment/Python/baby-steps-of-rl-ja/src/gym-ple/gym_ple/ple_env.py", line 62, in _render from gym.envs.classic_control import rendering File "/home/ec2-user/.pyenv/versions/3.6.5/lib/python3.6/site-packages/gym/envs/classic_control/rendering.py", line 34, in <module> ''') ImportError: Error occurred while running `from pyglet.gl import *` HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'. If you're running on a server, you may need a virtual frame buffer; something like this should work: 'xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>'

welcome.py

import numpy as np from tensorflow.python import keras as K import gym import gym_ple def welcome(): """ Code to check installation of basic libraries """ env = gym.make("Catcher-v0") num_action = env.action_space.n episode_count = 10 s = env.reset() brain = K.Sequential() brain.add(K.layers.Dense(num_action, input_shape=[np.prod(s.shape)], activation="softmax")) def policy(s): evaluation = brain.predict(np.array([s.flatten()])) return np.argmax(evaluation) for e in range(episode_count): s = env.reset() done = False while not done: env.render(mode="human") a = policy(s) n_state, reward, done, info = env.step(a) s = n_state if __name__ == "__main__": welcome()

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ベストアンサー

強化学習の題材として、Gym を利用しているようですが、ゲームなので動作させるために GUI 環境が必要です。
Amazon Linux は CUI 環境なので、その環境では実行できません。
OpenGL を使っていることからクラウド上で実行するのは難しいと思うので、ローカルのパソコンに Python を実行できる環境を作成して実行すればよいと思います。

投稿2019/12/29 18:21

編集2019/12/29 18:23
tiitoi

総合スコア21956

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

必要なパッケージがインストールされていないようです。

couldn't import doomish Couldn't import doom

pip install -r requirements.txt でエラーが発生しませんでしたか?

投稿2019/12/29 15:07

tatamyiwathy

総合スコア1039

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問