1.创建python2.7虚拟环境
cd C:\ProgramData\Anaconda3\envs
conda create -n th_py2 python=2.7
2.安装minGW,libpython
激活虚拟环境
activte th_py2
安装minGW,libpython
conda install mingw libpython
3. 安装theano
conda install theano
theano安装完成后可以在Anaconda2\Lib\site-packages\theano文件夹下找到theano的文件夹。然后不要忘记将该路径加入环境变量中,在我的电脑中路径如下:
C:\ProgramData\Anaconda3\envs\th_py2\Lib\site-packages\theano
4.配置路径文件
第一步,在你的电脑User目录下找到你的用户文件夹,l例如,登陆用户名是CC,然后在C:\Users\CC下新建文本文档,此时果断不要改名
第二步,在新建文本文档中输入如下命令:
[global]
openmp=False
[blas]
Idflags=
[gcc]
cxxflags=-IC:\ProgramData\Anaconda3\envs\th_py2\MinGW
注意路径是根据你自己的MinGW来设置的,不需要和我的一样
第三步,保存,改文本文档的名字为.theanorc.txt(注意theano前还有一个点)
最后一步,重启电脑
Step5 theano测试
从cmd进入python的shell脚本
输入如下指令:
>>> import theano
>>> theano.test()
或
python -c "import theano;theano.test()"
报错
To use MKL 2018 with Theano either update the numpy conda packages to
their latest build or set "MKL_THREADING_LAYER=GNU" in your
environment.
执行以下命令
conda uninstall mkl=2018
conda install mkl=2017
结果报错:
No module named theano
尝试再次安装theano
conda install theano
报错
No module named nose.config
尝试
conda install nose
报错
ImportError: No module named parameterized
尝试
conda install nose-parameterized
其他缺什么包安装什么包即可。
之后又遇到一直提示:
UserWarning: The file scan_perform.c is not available. This donot happen normally. You are probably in a strangesetup. This mean Theano can not use the cython code for scan. If youwant to remove this warning, use the Theano flag'cxx=' (set to an empty string) to disable all ccode generation.
尝试
conda uninstall theano
pip install theano
经过漫长的等待,得到OK<skip=159>
则安装成功。