简体   繁体   English

如何在Ubuntu 11.10 Oneiric中正确安装python-numpy

[英]How to correctly install python-numpy in Ubuntu 11.10 Oneiric

According to Scipy website, in Ubuntu 11.10 numpy and scipy comes pre-packaged so what I did was: 根据Scipy网站的说法,在Ubuntu 11.10中,numpy和scipy预先打包,所以我做的是:

apt-get install python2.7
apt-get install python-numpy
apt-get install python-scipy

Then I tried to call numpy in Python but get an error: 然后我试着在Python中调用numpy但是得到一个错误:

ImportError: cannot import name datetime_data.

Any ideas why this happened? 任何想法为什么会这样? Full error message attached. 附加完整的错误消息。


Python 2.7.2+ (default, Oct  4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 8, in <module>
    import numerictypes as nt
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/numerictypes.py", line 92, in <module>
    from numpy.core.multiarray import typeinfo, ndarray, array, \
ImportError: cannot import name datetime_data

It looks like you have a broken numpy install in /usr/local/lib/python2.7/dist-packages, the package manager installs numpy to /usr/lib/pyshared/python2.7 看起来你在/usr/local/lib/python2.7/dist-packages中有一个破坏的numpy安装,包管理器将numpy安装到/usr/lib/pyshared/python2.7

You should remove the broken numpy 你应该删除破碎的numpy

$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/numpy

then the numpy you installed with apt-get should work as expected. 那么你用apt-get安装的numpy应该按预期工作。

I had a similar problem after upgrading my numpy version. 升级我的numpy版本后,我遇到了类似的问题。 I solved it reinstalling and removing the numpy lib folder (for your python version) 我解决了它重新安装并删除numpy lib文件夹(对于你的python版本)

sudo apt-get remove python-numpy
sudo rm -r /usr/local/lib/pythonX.X/dist-packages/numpy
sudo apt-get install python-numpy

(or installing a new numpy version from any numpy package) (或从任何numpy包中安装新的numpy版本)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM