您当前的位置: 首页 > 技术文章 > 操作系统

linux/mac 安装 gym

作者: 时间:2023-05-12阅读数:人阅读

linux/mac 安装 gym

pip 安装

首先需要保证 python 版本是 3.7 及以上,否则可能会出问题。

第一步,升级 pip 到最新版

pip install pip -U

第二步,按照 Github 官方文档,有三种安装方式。这里我选择安装完整版 gum[all]

pip install gym  # 基础版,不包含某些环境依赖
pip install 'gym[atari]'  # 支持 Atari 游戏环境
pip install 'gym[all]'  # 完整版

如果你没有安装失败,那么恭喜你,gym 已经解决了这个问题。但如果你和我一样,遇到不存在 lockfile、 以及 box2d-py、mujoco-py 编译失败,那么就需要手动安装了,可以参考下面的手动安装步骤。

手动安装可以解决如下报错问题。

Building wheels for collected packages: box2d-py
Building wheel for box2d-py (setup.py) … error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
unable to execute ‘swig’: No such file or directory
error: command ‘swig’ failed with exit status 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for box2d-py
Running setup.py clean for box2d-py
Failed to build box2d-py

from lockfile import LockFile
ModuleNotFoundError: No module named ‘lockfile’

手动安装

如果你是 mac 电脑,需要先安装 swig。否则可以跳过这一步。

brew install swig

然后,手动安装 lockfile 依赖。

pip install lockfile

最后,克隆 gym 项目,修改安装文件后,手动安装。

git clone https://github.com/openai/gym.git
cd gym
vim setup.py  # 把 "mujoco": ["mujoco_py>=1.50, <2.0"] 这行注释掉,并保存
pip install -e '.[all]'

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:licqi@yunshuaiweb.com

标签: gym 强化学习
加载中~