Python錯誤集錦__Python

來源:互聯網
上載者:User

1. centos更新到python2.7時,無法正常使用方向鍵:


此問題原地址(感謝作者的分享): here
圖中的方向鍵全部被轉義了,在互動模式下使用非常不方便。 這個問題主要是由於缺少readline Module問題導致的。而CentOS預設只有readline模組而沒有readline-devel開發模組。所以只要安裝下即可。
#安裝readline-devel $yum -y install readline-devl #重新安裝python $./configure $make install
到此問題應該已經解決了。如果還是不行,可以嘗試使用Python內建的readline模組。 註:重新安裝python對之前所安裝的外掛程式無影響。 2. Win7 64位安裝 theano, ImportError: not import name gof 本文在32位機器上安裝theano時(之前需要安裝cygwin 或者mingw),之後輸入'from theano import *', 可以啟動,沒問題; 可是在筆記本win7 64位安裝theano,使用 'from theano import *'時,顯示進行一系列的貌似編譯的工作,之後在使用此命令時匯入theano時,最後提示:“ImportError: not import name gof”。 在網上沒有找到很好的關於gof的解決方案(有英文的,但是回答者也沒說清楚),說是先安裝libpython1.2,等等,重裝了幾次,最後提示“pythonw.exe已停止工作”,實在沒招了,因為急著要用,暫時沒時間解決這個問題,於是按照theano官網上說的使用Anaconda安裝,步驟如下: ① 首先下載並安裝Anaconda,下載地址:http://www.continuum.io/downloads,本文現在windows 64 ② 下載安裝Windows installer for Theano on AnacondaCE for Windows.:地址:http://deeplearning.net/software/theano/install.html#windows-anaconda 下載theano的zip檔案: https://github.com/Theano/Theano  ,解壓到E:/Anaconda/Lib/site-packages/theano( 檔案裡面有個theano的檔案夾,拿出來放在E:/Anaconda/Lib/site-packages裡面 )目錄下。 添加環境變數:    path: E:/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 win7 64位安裝,可參考:Deep Learning 開發工具Theano安裝配置 本人PC機(32位)安裝Anaconda和Theano的步驟:
1. 首先安裝MinGW,預設安裝在C:/MinGW, 配置環境變數:PATH= ...; C:/MinGW/bin 2. 安裝Anaconda-32.exe 從官網上下載, 配置環境變數;參看:Deep Learning Theano安裝配置 3. 手動設定theano, 下載theano.zip檔案,解壓導‘Anaconda安裝目錄/Lib/site-packages/theano’中, 在'C:/users/使用者名稱'目錄下,建立'.theanorc.txt'檔案,輸入以下內容: [global] openmp=False [blas] ldflags= [gcc] cxxflags = -IC:/MinGW/include 之後,在CMD中,測試是否安裝成功:
分別輸入 python, import theano, print theano.config.blas.ldflags 如果沒有出錯,則說明安裝成功 註: win7下已如果安裝cygwin而不是mingw, 進行import theano時,可能多次編譯,並提示'ImportError: not import name gof'錯誤,theano官網上有說明:"Note that it should be possible to run Theano withCygwin instead of MinGW, but this has not been tested yet", 這說明cygwin不能安裝成功,本人之前安裝的是cygwin,不得已換成mingw~ 3. Centos6.4 安裝theano出現的錯誤: 在安裝好numpy、scipy、theano後。 
在python代碼中,敲入:import theano,報錯如下: 
Error代碼   Problem occurred during compilation with the command line below:      g++ -shared -g -m64 -fPIC -I/usr/local/lib/python2.7/site-packages/numpy/cor   e/include -I/usr/local/include/python2.7 -o /root/.theano/compiledir_Linux-2   .6.18-308.el5-x86_64-with-redhat-5.8-Tikanga-x86_64-2.7.3-64/lazylinker_ext/   lazylinker_ext.so /root/.theano/compiledir_Linux-2.6.18-308.el5-x86_64-with-   redhat-5.8-Tikanga-x86_64-2.7.3-64/lazylinker_ext/mod.cpp -L/usr/local/lib -   lpython2.7      /usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_   32 against `a local symbol' can not be used when making a shared object; rec   ompile with -fPIC      /usr/local/lib/libpython2.7.a: could not read symbols: Bad value      collect2: ld returned 1 exit status      Traceback (most recent call last):        File "<stdin>", line 1, in <module>        File "theano/__init__.py", line 55, in <module>          from theano.compile import \        File "theano/compile/__init__.py", line 5, in <module>          from theano.compile.function_module import *        File "theano/compile/function_module.py", line 18, in <module>          import theano.compile.mode        File "theano/compile/mode.py", line 11, in <module>          import theano.gof.vm        File "theano/gof/vm.py", line 486, in <module>          import lazylinker_c        File "theano/gof/lazylinker_c.py", line 89, in <module>          preargs=args)        File "theano/gof/cmodule.py", line 1829, in compile_str          (status, compile_stderr.replace(b('\n'), b('. '))))      Exception: Compilation failed (return status=1): /usr/bin/ld: /usr/local/lib   /libpython2.7.a(abstract.o): relocation R_

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.