Python Windows 上的 OpenAI Gym Atari

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42605769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:57:10  来源:igfitidea点击:

OpenAI Gym Atari on Windows

pythonwindowsopenai-gym

提问by dant

I'm having issues installing OpenAI Gym Atari environment on Windows 10. I have successfully installed and used OpenAI Gym already on the same system.

我在 Windows 10 上安装 OpenAI Gym Atari 环境时遇到问题。我已经在同一系统上成功安装并使用了 OpenAI Gym。

It keeps tripping up when trying to run a makefile.

尝试运行 makefile 时,它​​不断跳闸。

I am running the command pip install gym[atari]

我正在运行命令 pip install gym[atari]

Here is the error:

这是错误:

enter image description here

在此处输入图片说明

and here is what I currently have on my system...cmakeand makeare both clearly installed.

这是我目前在我的系统上的内容......cmake并且make都清楚地安装了。

enter image description here

在此处输入图片说明

采纳答案by dant

I ended up installing Bash on Ubuntu on Windows and using it to run the OpenAI Gym / Atari environment. OpenAI Gym has very limited support for Windows at the moment.

我最终在 Windows 上的 Ubuntu 上安装了 Bash,并使用它来运行 OpenAI Gym / Atari 环境。OpenAI Gym 目前对 Windows 的支持非常有限。

回答by Nikita Kniazev

A while ago I have created a fork with Windows support (devs of original repository do not merge or even comment PRs and issues). It does not require neither MSYS/Cygwin nor CMake or Zlib.

不久前,我创建了一个支持 Windows 的 fork(原始存储库的开发人员不会合并甚至评论 PR 和问题)。它既不需要 MSYS/Cygwin,也不需要 CMake 或 Zlib。

To simply install atari-pywheels (binaries)use this command:

要简单地安装atari-py轮子(二进制文件),请使用以下命令:

pip install --no-index -f https://github.com/Kojoley/atari-py/releases atari_py

If you have any distutilssupported compiler you can install from sources:

如果您有任何distutils受支持的编译器,您可以从源代码安装:

pip install git+https://github.com/Kojoley/atari-py.git

Test your installation with a simple example:

用一个简单的例子测试你的安装:

import gym
env = gym.make('SpaceInvaders-v0')
env.reset()
for _ in range(1000):
    env.step(env.action_space.sample())
    env.render('human')
env.close()  # https://github.com/openai/gym/issues/893

If your got a 'scrambled' output that's most likely because your gymis outdated.

如果您得到“乱码”输出,那很可能是因为您gym.

回答by AwokeKnowing

This is not fully tested, because I don't remember exactly what I did, but currently I have openAI gym running with all the atari games set up and displaying, and also matplotlib plots, all while using ubuntu on windows (WSL). In fact I have sublimetext3 and spider working too.

这没有经过全面测试,因为我不记得我做了什么,但目前我有 openAI 健身房运行,所有 atari 游戏设置和显示,还有 matplotlib 图,同时在 windows (WSL) 上使用 ubuntu。事实上,我也有 sublimetext3 和蜘蛛工作。

So take these as a guide, but I don't have "clean" environment to test them on.

所以以这些为指导,但我没有“干净”的环境来测试它们。

First, in Windows, Google "xming" (x11 server) and download from sourceforge / install / run. This is what makes it all possible.

首先,在Windows 中,谷歌“xming”(x11 服务器)并从sourceforge 下载/安装/运行。这就是使这一切成为可能的原因。

Now in WSL bash install the display stuff to work with xming

现在在 WSL bash 中安装显示内容以与 xming 一起使用

sudo apt-get install x11-apps
export DISPLAY=localhost:0.0 
nano ~/.bashrc  #(add  export DISPLAY=localhost:0.0   at the end. Ctrl+X to exit/save)
sudo apt-get install gnome-calculator #will get you GTK

Now in WSL bash install Anaconda. this will involve downloading the .sh file (eg with curl -O "[the http link to latest anaconda]" and running it with bash [the file].sh. Don't use sudo when installing Anaconda.

现在在 WSL bash 中安装 Anaconda。这将涉及下载 .sh 文件(例如使用 curl -O“[最新 anaconda 的 http 链接]”并使用bash [the file].sh.运行它。安装 Anaconda 时不要使用 sudo。

With anaconda installed, close WSL, and restart it. Now make an environment and activate it

安装 anaconda 后,关闭 WSL,然后重新启动它。现在创建一个环境并激活它

conda create -n gym python=3.5 anaconda
source activate gym

Now get the gym repo

现在得到健身房回购

git clone https://github.com/openai/gym.git
cd gym

Now install these gym dependencies mentioned on openai gym repo

现在安装 openai 健身房 repo 上提到的这些健身房依赖项

apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig

Now install libgcc with conda

现在用 conda 安装 libgcc

conda install libgcc

Now build gym

现在建健身房

pip install -e '.[all]'

That's basically it. make sure Xming is running on windows, and in WSL type gnome-calculator, and it should bring up the calculator. if it doesn't, keep working on the display side. If it does, try running some of the agents in the gym examples folder.

基本上就是这样。确保 Xming 在 Windows 上运行,并在 WSL 中输入 gnome-calculator,它应该会调出计算器。如果没有,请继续在显示端工作。如果是,请尝试运行 Gym 示例文件夹中的一些代理。

I may have missed a couple extra dependencies along the way, but these would have been things I figured out based on error messages.

在此过程中,我可能错过了一些额外的依赖项,但这些都是我根据错误消息发现的。

Here's the pic to keep you motivated: enter image description here

这是让你保持动力的图片: 在此处输入图片说明

EDIT:Today I ran the following command which installed Qt5 as the back end, and matplotlib is working fine with Qt5Agg as the back end (vs TkAgg). This may be helpful if you're running some thing else on WSL which needs Qt5

编辑:今天我运行了以下命令,该命令将 Qt5 安装为后端,并且 matplotlib 与 Qt5Agg 作为后端(与 TkAgg)一起工作正常。如果您在 WSL 上运行其他需要 Qt5 的东西,这可能会有所帮助

sudo apt-get update && sudo apt-get install qtbase5-dev

sudo apt-get update && sudo apt-get install qtbase5-dev

Also, to find your matplotlibrc, and command prompt type: python import matplotlib print(matplotlib.matplotlib_fname()) quit()

此外,要找到您的 matplotlibrc,并在命令提示符下键入: python import matplotlib print(matplotlib.matplotlib_fname()) quit()

Please note that there is NO GPU SUPPORTon ubuntu for windows. This is the top requested feature at uservoice, yet MS has it on "backlog". If you're interested, vote here

请注意,windows 的 ubuntu 上没有 GPU 支持。这是 uservoice 最需要的功能,但 MS 把它放在“积压”上。如果您有兴趣,请在这里投票

回答by iva2k

I encountered that gymnow requires later version v0.1.4 of atari-pythan any of other cloned repos.

我遇到了gym现在需要atari-py比任何其他克隆存储库更高版本的 v0.1.4 。

Thanks to Nikita Kniazev - I ported his Windows edits to latest code from openai/atari-py and got gymworking.

感谢 Nikita Kniazev - 我将他的 Windows 编辑移植到 openai/atari-py 的最新代码并开始gym工作。

Use: pip install git+https://github.com/Kojoley/atari-py.git

用: pip install git+https://github.com/Kojoley/atari-py.git

回答by Zeyd

I had the same issue with the atari-pyenvironment. Then I followed the steps in the Openai GitHuband then it worked.

我对atari-py环境有同样的问题。然后我按照Openai GitHub 中的步骤操作,然后就成功了。