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  

(四)總結

  綜上是我安裝過程當中遇到的一些錯誤以及解決方案,歡迎討論。

相關文章
相關標籤/搜索