源码:https://github.com/thu-media/Comyco
1. 运行rl_test.py
创建python版本为3.6的anaconda环境,命名为comyco
conda create -n comyco python=3.6
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy tensorflow==1.12.0 tflearn sklearn
注:tflearn不能在tensorflow2.0下使用,所以要限制tensorflow的版本为1.12.0.
按照下面的命令安装swig时出现错误。
pip install swig
ERROR: Could not find a version that satisfies the requirement swig (from versions: none)
ERROR: No matching distribution found for swig
按照下面命令用conda安装swig
conda install swig
pip install pydotplus
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple statsmodels
2. 运行train.py
(1) 安装swig
https://www.dev2qa.com/how-to-install-swig-on-macos-linux-and-windows/
出现问题:
swig: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
按照如下链接安装pcre-8.43后拷贝libpcre.so.1到/usr/lib/后能够运行:
https://blog.csdn.net/will199321/article/details/87920904
https://unix.stackexchange.com/questions/421257/swig-error-in-ubuntu-16-04
xcc:~/download/pcre-8.43/.libs$ swig -version
SWIG Version 4.0.1
Compiled with g++ [x86_64-pc-linux-gnu]
Configured options: +pcre
Please see http://www.swig.org for reporting bugs and further information
(2) 生成_envcpp.so
使用linux环境下的代码。
swig -c++ -python abr.i
g++ abr_wrap.cxx env.cpp -fPIC -shared -I /home/xcc/anaconda2/envs/comyco/include -I /home/xcc/anaconda2/envs/comyco/include/python3.6m -L /home/xcc/anaconda2/envs/comyco/lib -o _envcpp.so -O4
然后把生成的envcpp.py
和_envcpp.so
拷贝到/Comyco/src/文件夹下,就可以运行train.py了。
相关链接:
https://stackoverflow.com/questions/4095083/swig-no-module-named-example
http://www.swig.org/Doc1.3/Python.html#Python_nn72
http://www.swig.org/papers/PyTutorial98/PyTutorial98.pdf
网友评论