Numpy install under Ubuntu (12.04) causes Python ImportError

天涯浪子 提交于 2019-12-10 11:45:26

问题


Under Ubuntu (12.04), installed python (2.7.5) with numpy (1.8rc2) using openblas into own environment (/din). The numpy site.cfg file is configured to point to openblas, and compiled as:

$ python setup.py build
$ sudo python setup.py install --prefix=/home/Programs/din/local

$ python

Python 2.7.5 (default, Oct 24 2013, 15:33:08)
[GCC 4.6.3] 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 "/home/Programs/din/local/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/home/Programs/din/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
    import multiarray
ImportError: 
"/home/Programs/din/local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: ERR_peek_last_error

Cython, gevent, and other python packages have all been installed successfully into /din but not numpy. The $PATH and python sys.path have been checked and all looks good.

Does anyone have ideas to try out?


回答1:


This may not directly address your specific problem, but if you're on Ubuntu 12.04, you can just apt-get. Then, because the version will not be the latest, I then do pip install --upgrade. Doing apt-get before pip first magically seems to install the right dependencies as well; if I do pip install first, it doesn't work.

Specifically:

sudo apt-get install python-numpy python-scipy libblas-dev liblapack-dev gfortran python-dev
sudo pip install numpy --upgrade
sudo pip install scipy --upgrade


来源:https://stackoverflow.com/questions/19693302/numpy-install-under-ubuntu-12-04-causes-python-importerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!