我使用適用於MacOS 10.5和Python 2.5的Mac磁盤映像安裝程序安裝了matplotlib。我安裝numpy然後試圖導入matplotlib但得到這個錯誤:ImportError: numpy 1.1 or later is required; you have 2.0.0.dev8462
。看來版本2.0.0.dev8462會晚於版本1.1,但我猜測matplotlib與版本中的「.dev8462」混淆了。有沒有解決這個問題的方法?無法導入matplotlib
1
A
回答
1
這裏是位於Lib/site-packages/matplotlib/__init__.py
在我的Python分佈Windows上的麻煩的代碼
nn = numpy.__version__.split('.')
if not (int(nn[0]) >= 1 and int(nn[1]) >= 1):
raise ImportError(
'numpy 1.1 or later is required; you have %s' % numpy.__version__)
的問題是,它需要同時第一至數字(由句點分隔)爲大於或等於1在你的情況下,第二位是2.您可以繞過這在許多方面,但一個辦法就是if語句改爲
if not ((int(nn[0]) >= 1 and int(nn[1]) >= 1) or int(nn[0]) >= 2):
,或者你可以只將其更改爲:
if not (float('.'.join(nn[2:])) >= 1.1):
這可能會更好。
+0
+1。但是這是一個更簡單的版本:'(int(nn [0]),int(nn [1]))> =(1,1)'。實際上,元組與所謂的「字典順序」相比較。 – EOL 2010-06-14 08:41:54
0
繼賈斯汀的評論...這裏是Linux的相應文件:
/usr/lib/pymodules/python2.6/matplotlib/__init__.py
sudo的編輯來解決麻煩的線路: 如果不是((INT(NN [0])> = 1和int(nn [1])> = 1)或int(nn [0])> = 2):
謝謝Justin Peel!
相關問題
- 1. 無法導入matplotlib pyplot
- 2. Python/Eclipse無法導入MatPlotLib
- 3. matplotlib ImportError:無法導入名稱'樣式'
- 4. 無法在Paraview中導入matplotlib
- 5. python3.3 matplotlib無法導入名稱_tkagg
- 6. matplotlib進口,但pyplot無法導入
- 7. 無法從Python中的Matplotlib導入FigureCanvasWxAgg
- 8. 由於未能導入unichr導致Python無法導入matplotlib
- 9. ImportError:無法導入名稱mpl(來自matplotlib導入mpl)
- 10. 無法在Mac中從Python卸載matplotlib,numpy和scipy。無法從virtualenv導入matplotlib
- 11. 無法安裝matplotlib 1.3 - 由於dateutil導致導入失敗
- 12. Pycharm - 導入Matplotlib
- 13. Ubuntu上的Matplotlib錯誤「無法導入名稱pyplot」
- 14. ubuntu python anaconda2:激活tensorflow後無法導入matplotlib
- 15. 無法導入Matplotlib Python 2.7版的Windows 7
- 16. 無法導入matplotlib即使它安裝了
- 17. matplotlib導入錯誤:無法加載所需的Qt結合
- 18. 無法導入
- 19. 無法導入
- 20. DSS WSDL1.1 WCF給出無法導入wsdl:binding,無法導入wsdl:port,無法導入wsdl:
- 21. Matplotlib + Pylab導入錯誤
- 22. 使用PyScripter導入matplotlib
- 23. 在Ubuntu上導入matplotlib
- 24. 在Python中導入matplotlib
- 25. Matplotlib沒有正確導入
- 26. %matplotlib inline magic導入錯誤
- 27. 錯誤導入蟒蛇matplotlib
- 28. matplotlib導入錯誤python
- 29. 無法導入PhoneLookup?
- 30. 無法導入android.os.strictmode
Numpy 2.0不與matplotlib向後兼容,如果您嘗試在其上運行matplotlib,它將會*崩潰。如果你想運行numpy 2. *,你需要重建每個使用numpy C API(matplotlib,scipy等)的包。 – 2010-06-14 06:40:37