python 安裝pandas包時出現ImportError: Building pandas requires cython
阿新 • • 發佈:2019-02-17
pandas有強大的資料處理能力,在本機安裝(Windows),沒有遇到什麼問題,但是在伺服器上安裝時(centos),使用easy_install的方式,下載及其緩慢,於是就將本地把包下好,然後上傳到伺服器上,解壓後,然後使用命令:
sudo ./../python setup.py install
提示如下錯誤
File "./setup.py", line 131, in build_extensions
raise ImportError('Building pandas requires cython')
ImportError: Building pandas requires cython
檢查Cython的安裝情況,發現也是安裝了的
sudo ./easy_install Cython
Searching for Cython
Best match: Cython 0.19
Adding Cython 0.19 to easy-install.pth file
Using /home/q/python27/lib/python2.7/site-packages
Processing dependencies for Cython
Finished processing dependencies for Cython
google了一下,幾乎沒找到相關的解決方案。於是開啟setup.py,看了丟擲異常的路徑:
class build_ext(_build_ext):
128 def build_extensions(self):
129
130 if not cython:
131 **raise ImportError('Building pandas requires cython')**
132
檢查下cython的值:
32 min_cython_ver = '0.19.1'
33 try:
34 import Cython
35 ver = Cython.__version__
36 _CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
37 except ImportError:
38 _CYTHON_INSTALLED = False
明顯,這是因為我的cython版本過低導致,
>>> Cython.__version__
'0.19'
於是重新升級了cython的版本,問題解決了。