一、问题陈述
本人在学习Stabe-Baselines3的过程中,遇到的代码中,使用了box-2D模块,为了使代码正常运行,需要安装该模块。本人是在conda环境下运行pycharm,在pycharm终端进行box-2D安装。
一、网络现有方法
1、Stable-Baselines3官方文档给出了一种安装方法:先安装swig,再安装box2D。
原文如下:
LunarLander requires the python package box2d
. You can install it using apt install swig
and then pip install box2d box2d-kengz
依照该过程进行安装,首先手动下载swig(win10中 默认没有apt命令),将其解压至某一特定路径P,再把路径P添加到环境变量的PATH中,接下来运行
pip install box2d box2d-kengz
出现下面的报错
ERROR: Could not find a version that satisfies the requirement box2d (from versions: none)
ERROR: No matching distribution found for box2d
该方法无效。
2、CSDN上找到的一种方法:手动下载box-2d,再通过命令安装
在https://www.lfd.uci.edu/~gohlke/pythonlibs/#pybox2d搜索需要的版本
pip安装,如:
pip install Box2D-2.3.2-cp36-cp36m-win_amd64.whl
出现如下的报错
ERROR: Box2D-2.3.2-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
二、解决了问题的方法
本人已经安装完gym,在知乎上找到了一个利用conda安装box-2d的方法:
conda install -c conda-forge box2d-py
实测有效
box-2d可以正常使用