Windows下pycharm使用theano的方法

  安装theano前须要自行安装Anaconda和PyCharm。在网上查了在PyCharm上安装theano的方法,可是均遇到了一些问题,现将问题与解决方案介绍以下。python

(一)第一种安装方式git

  打开cmd命令窗口或者Anaconda命令窗口,输入 pip install theano。 github

  回车后看到下载与安装的进度条,可是这样安装事后直接import theano会报错。因而我又使用了第二种方法。测试

(二)第二种安装方式spa

  1.手动下载theano的zip文件ip

  下载地址:https://github.com/Theano/Theano ,解压后找到XXX/Anaconda/Lib/site-packages/theano(文件里面有个theano的文件夹)get

  将这个文件夹复制粘贴到E:/Anaconda/Lib/site-packages里面)(这个路径是你本身Anaconda的路径)。cmd

  2.查看你的Anaconda路径下有没有MinGW文件夹,若是有,直接跳到第3步。it

  下面安装MinGW包,CMD输入conda install mingw libpython ,MinGW会自动装到Anaconda下。pip

  3.配置环境变量。 

  添加环境变量:path: XXX/Anaconda/MinGW/bin;E:/Anaconda/MinGW/x86_64-w64-mingw32/lib;(按照本身的路径修改)  

                                (32bit  E:/Anaconda/MinGW/i686-w64-mingw32/lib;)   

       新建环境变量:  PYTHONPATH: E:/Anaconda/Lib/site-packages/theano;

(三)测试theano

  cmd中,输入python进入python环境下,输入import theano回车,若是没有error则配置成功。

(四)出现的问题

  1.WARNING (theano.configdefaults): g++not available, if using conda: `conda install m2w64-toolchain`

     WARNING (theano.configdefaults): g++not detected ! Theano will be unable to execute optimized C- imp

    解决方法:cmd窗口输入conda install m2w64-toolchain

  2.cmd命令窗口输入conda list,查看有没有libpython,若是没有,则解决方法:

  cmd窗口输入conda install libpython

  3.Traceback (most recent call last):
           File "", line 1, in
           File "E:\jing\Anaconda\lib\site-packages\theano__init__.py", line 55, in  from theano.compile import \
           File "E:\jing\Anaconda\lib\site-packages\theano\compile__init__.py", line 9, in   from theano.compile.function_module import *
           File "E:\jing\Anaconda\lib\site-packages\theano\compile\function_module.py", line 16, in from theano import gof
           ImportError: cannot import name gof

  明明有gof,可是显示没法导入。

  解决方法:在“C:/USERS/用户名”目录下(根据电脑不一样这个可能不一样,若是不知道能够经过cmd查询,默认的就是这个路径)。

  找到这个路径后,新建“.theanorc.txt”文件,输入如下内容:

  [global]

    openmp=False
  [blas]
  ldflags=
  [gcc]
  cxxflags = -IC:/MinGW/include  

(四)总结

  综上是我安装过程当中遇到的一些错误以及解决方案,欢迎讨论。