使用pip安装irl-benchmark的运行环境
#2019.8.16-0:00-14:00
目录
0 安装目的
为了运行有关逆强化学习的示例代码,必须安装irl-benchmark的运行环境
此为该示例代码的链接:
https://github.com/JohannesHeidecke/irl-benchmark
想要学习强化学习的小伙伴可以先看看“莫烦python”的强化学习教学视频
irl-benchmark简介:
irl-benchmark
is a modular library for evaluating various Inverse Reinforcement Learning algorithms. It provides an extensible platform for experimenting with different environments, algorithms and metrics.
1 各种安装方法的比较
1.使用anaconda或winpython里的辅助软件进行套件安装:
优点:简单易用(适合新手),基本上不会出现pip安装中的各种问题。
缺点:必须一项一项的安装,不能配置详细的安装参数,也不能同时安装多个包。
2.使用terminal中的pip安装:
优点:适合已经崩溃过无数次的程序猿老司机,熟练的使用各种参数和命令能够帮助你避免很多error
缺点:会遇到很多问题,需要很强的毅力和恒心
2 使用pip安装的原因
1.anaconda-navigator在安装包的时候总是会报错: anaconda 无法定位程序输入点 openssl_sk_new_reserve 于动态链接库
因此,无法使用该软件进行套件安装
2.之前也使用过pip,感觉使用pip安装也不难(结果遇到了各种问题,让人神伤)
3 安装步骤
1.查看github上JohannesHeidecke的installation:
conda create --name irl-benchmark python=3.6
source activate irl-benchmark
pip install -r requirements.txt
2.打开terminal(快捷键win+r),输入:
conda create --name irl-benchmark python=3.6
接下来按照提示输入即可,创建成功
3.在terminal中,输入:
conda activate irl-benchmark (进入该环境)
e: (从初始位置转换到e盘,为cd到irl-benchmark的下载目录做准备)
cd E:\HJN\Documents\irl-benchmark(进入irl-benchmark的下载目录,不进入该目录,pip找不到requirements.txt)
pip install -r requirements.txt(开始安装)
4 安装遇到的问题
1.找不到对应的版本1
Could not find a version that satisfies the requirement gym>=0.10.5 (from -r requirements.txt (line 1)) (from versions: ) No matching distribution found for gym>=0.10.5 (from -r requirements.txt (line 1))
解决方法:
1、可能是pip的版本太旧,升级pip的版本之后,重新安装;
2、重新输入命令,多试几次
2.超时
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
解决方法:
1、更改pip默认的超时限制时间,在输入命令时,添加参数:
pip --default-timeout=100 install XXX(100可以换成其他任何数字,XXX是你要安装的包的名称)
3.找不到相应的模块
ModuleNotFoundError: No module named 'setuptools._deprecation_warning'
解决方法:
1、找不到对应的模块,那就安装对应的模块:
pip install --upgrade setuptools(setuptools是本次安装缺失的模块)
4.找不到对应的版本2
ERROR: Could not find a version that satisfies the requirement torch>=0.4.0 (from -r requirements.txt (line 9)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch>=0.4.0 (from -r requirements.txt (line 9))
解决方法:
1、添加参数,使pip从pytorch的官网下载对应的包,输入:
pip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
5.预装包未提前安装
c:\users\hjn.conda\envs\irl-benchmark\lib\site-packages\numpy\distutils\system_info.py:690: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [blas_src]) or by setting the BLAS_SRC environment variable.
解决方法:
1、按顺序安装包,先安装numpy+mkl+blas,再安装scipy和scs
6.缺少相关的编译工具
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
补充信息:ERROR: Failed building wheel for scs
分析:(引用自https://blog.51cto.com/xvjunjie/2178955?source=dra,此为51CTO博客作者BlueMiaomiao的原创作品)
缺少编译scs的C++编译工具,经过查阅得知:
Python 2.7需要Microsoft Visual C++ 9.0的库 Python 3.6需要Microsoft Visual C++ 14.0的库
两种解决方案:
-
下载whl文件直接安装(Python2和Python3适用)
下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/ 在这里可以搜索你想要的库!!!(要翻墙) 使用 pip install xxx.whl 安装即可。
-
下载Microsoft Visual C++ Build Tools(Python3适用)
下载微软的C++编译工具,CSDN上下载竟然花钱,气死我了...我特么还是学生呢...在这里下载吧,免费的:http://down.51cto.com/data/2452424 下载完成使用管理员权限打开,安装Windows10SDK和.NET框架即可!!!
实际解决手段:
1、从https://www.lfd.uci.edu/~gohlke/pythonlibs/#scs中下载对应的whl文件:scs‑2.1.1.post2‑cp36‑cp36m‑win_amd64.whl
注:cp36对应python3.6版本,win32对应windows32位,win_amd64对应windows64位
2、在terminal中,先把当前目录转换到下载目录,再输入:
pip install xxx.whl
7.找不到对应的版本3
解决方法:
1、不使用pip安装blas,使用conda安装blas。
原因:可能是pip中没有blas的资源
#2019.8.16.16:00更新
8.下载源出错
ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port=443):
解决方法:
第一步:在命令行中输入并运行(只是换了一个下载源:清华镜像):
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
第二步:更改配置文件
按上面的设置镜像源后,再打开C:\Users\Administrator\.condarc这个文件,删除" - defaults"这一行
5 安装成功的标准
1.terminal中显示如下:
2.使用vs code打开github库中的irl-benchmark
3.vs code中的problems面板没有显示任何错误,如图所示:
6 总结
1.有些包的安装需要预装一些包,虽然anaconda-navigator不能安装包,但是可以显示如下界面:
该界面提供了预装包的信息,可以根据信息按照顺序安装包
2.有的时候要使用conda命令安装(比如:blas——动态链接库),而不是用pip命令安装
P.S.有问题还会继续更新,欢迎各位与我一起交流学习