linux/mac 安装 gym

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]'
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值