16

我正在运行默认附带的 Ubuntu 12.04 NumPy 1.6.0(我实际上已经Python 2.7.3安装了)。由于这个问题polyfit() got an unexpected keyword argument 'w'的答案,我需要升级它。

我从这里.tar.gz下载了该版本的包,解压缩,移到文件夹中并运行命令:1.8.0

python setup.py build --fcompiler=gnu95
python setup.py install --user

用户指南和此问题中所述:在 Ubuntu 上构建 NumPy 1.7.1

这导致NumPy不再加载Spyder,现在显示错误:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/spyderlib/scientific_startup.py", line 16, in <module>
    from pylab import *  #analysis:ignore
  File "/usr/local/lib/python2.7/dist-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 165, in <module>
    from matplotlib.rcsetup import (defaultParams,
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/rcsetup.py", line 20, in <module>
    from matplotlib.colors import is_color_like
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/colors.py", line 52, in <module>
    import numpy as np
  File "/home/gabriel/.local/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
    from . import add_newdocs
  File "/home/gabriel/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/gabriel/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/home/gabriel/.local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/home/gabriel/.local/lib/python2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
    from . import multiarray
ImportError: /home/gabriel/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS2_FromUnicode

在加载它。当我尝试使用 version 时发生了同样的情况1.7.1

我尝试删除numpy

sudo apt-get remove python-numpy

这也删除了matplotlibscipy。所以我尝试重新安装它们:

sudo apt-get install python-numpy python-scipy python-matplotlib

但这失败并出现错误:

    from sre_constants import *
  File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

现在我没有运行 python,我什至不知道如何回到以前的稳定版本。所以问题是:我可以在我的系统中安装至少一个版本吗?1.7.1如果不能,我该如何回到工作1.6.0版本?谢谢。

4

2 回答 2

50
sudo pip install numpy --upgrade

会以更少的努力做同样的事情。

于 2014-02-22T20:07:49.180 回答
8

好的,所以我尝试了:

pip uninstall numpy

返回:

Successfully uninstalled numpy

所以我做了:

pip install numpy

但它说:

Requirement already satisfied (use --upgrade to upgrade): numpy in /home/gabriel/.local/lib/python2.7/site-packages
Cleaning up...

所以显然它仍然存在。我删除了该文件夹的内容,然后我只是做了:

sudo pip install numpy

这就像变态的魔法。现在我已经NumPy 1.8.0, SciPy 0.12.0, Matplotlib 1.2.1安装了,一切都在正常运行。

于 2013-11-07T15:55:52.440 回答