我很累尝试为phyton 2.7.5安装numpy和scipy,我需要此版本的python,因为我的最终目标是安装类(http://class-code.net/)和montepython(http:// montepython .net /)。
(我有Ubuntu 12.04)
当我尝试导入numpy或scipy时,每次都会出现以下错误:
$ phyton2.7
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/scipy/__init__.py", line 78, in <module>
from numpy import show_config as show_numpy_config
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
为了摆脱错误,我尝试过:
- 满足python要求:
$ sudo apt-get install build-essential python-dev gfortran
- 使用apt-get安装:
$ sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
- 用pip安装要求:
$ sudo pip install requests
- ...并尝试使用pip安装:
$ sudo pip install numpy
和$ sudo pip install scipy
- 我已经有环境var:
export PYTHONPATH=/usr/lib/python2.7/dist-packages:${PYTHONPATH}
上次安装numpy和scipy(在较早的ubuntu版本10.x中)对我有用。 sudo sh -c "wget http://python-distribute.org/distribute_setup.py -O- | python"
sudo sh -c "wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py -O- | python"
然后使用(4)中的pip安装它们但是现在看来python-distribute.org的服务器已关闭。我收到以下错误:
http://python-distribute.org/distribute_setup.py Resolving python-distribute.org (python-distribute.org)... failed: Name or service not known. wget: unable to resolve host address `python-distribute.org'
我还尝试从Synaptic和Ubuntu软件中心安装numpy和scipy
我在每次尝试中都失败了,现在我不知道该怎么办。我想念什么吗?如何为python正确安装numpy和scipy?任何想法将不胜感激。
当我做
echo $PYTHONPATH
我懂了
/usr/lib/python2.7/dist-packages
$PYTHONPATH
我已经删除了中的定义.bashrc
,但是我仍然在其他地方有一个定义,因为我仍然有可以获取的env var $PYTHONPATH
:(bash: /usr/lib/python2.7/dist-packages:: No such file or directory
双冒号)...
.bashrc
文件来纠正了export PYTHONPATH=/usr/lib/python2.7/dist-packages
...我做了UCS4 build / UCS2 build作为@Rmano sugest,但是在两种情况下我仍然遇到相同的问题...:\
echo $PYTHONPATH
到您的问题中。谢谢您:-)