windows环境下安装theano

本文详细介绍了在Python2.7环境下创建虚拟环境、安装Theano及相关依赖的过程。包括激活虚拟环境、配置路径文件及解决安装过程中遇到的常见错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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> 则安装成功。

参考资料

  1. https://www.jianshu.com/p/7ce3aab9792b
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值