在Ubuntu 12.04上升级到numpy 1.8.0

时间:2022-04-04 01:36:42

I'm running Ubuntu 12.04 which comes by default with NumPy 1.6.0 (I have, actually had, Python 2.7.3 installed). As a result of the answer to this question polyfit() got an unexpected keyword argument 'w', I need to upgrade it.

我正在运行Ubuntu 12.04,它默认使用NumPy 1.6.0(我已经安装了Python 2.7.3)。由于这个问题的答案polyfit()得到了一个意想不到的关键字参数“w”,我需要对它进行升级。

I downloaded the .tar.gz package for the version 1.8.0 from here, unpacked it, moved inside the folder and run the commands:

我下载的. tar。从这里打开1.8.0版本的gz包,移动到文件夹中并运行以下命令:

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

as described in the user guide and in this question: Building NumPy 1.7.1 on Ubuntu.

正如用户指南和本问题中所描述的:在Ubuntu上构建NumPy 1.7.1。

This resulted in NumPy no longer loading in Spyder, which now shows the error:

这导致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

upon loading it. The same happened when I tried with version 1.7.1.

在加载它。同样的事情也发生在我尝试使用1.7.1版本时。

I tried removing numpy with:

我试着用:

sudo apt-get remove python-numpy

which also removed matplotlib and scipy. So then I tried reinstalling them with:

也去除了matplotlib和scipy。于是我试着重新安装:

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

but this fails with the error:

但是这个错误却失败了:

    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

Now I'm left with no running python and I don't even know how to go back to the previous stable version. So the question: can I install at least version 1.7.1 in my system and if not, how do I go back to a working 1.6.0 version? Thanks.

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

2 个解决方案

#1


50  

sudo pip install numpy --upgrade

will do the same thing with slightly less effort.

将做同样的事情稍微少做一点努力。

#2


8  

Ok, so I tried:

好的,我试着:

pip uninstall numpy

which returned:

返回:

Successfully uninstalled numpy

So then I did:

然后我做了:

pip install numpy

but it said:

但它说:

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

so apparently it was still there. I removed the contents of that folder and then I simply did:

显然它还在那里。我删除了那个文件夹的内容,然后我就这么做了:

sudo pip install numpy

This worked like freaking magic. Now I have NumPy 1.8.0, SciPy 0.12.0, Matplotlib 1.2.1 installed and everything is running like it should.

这就像变魔术一样。现在,我已经安装了NumPy 1.8.0、SciPy 0.12.0、Matplotlib 1.2.1,并且一切都运行正常。

#1


50  

sudo pip install numpy --upgrade

will do the same thing with slightly less effort.

将做同样的事情稍微少做一点努力。

#2


8  

Ok, so I tried:

好的,我试着:

pip uninstall numpy

which returned:

返回:

Successfully uninstalled numpy

So then I did:

然后我做了:

pip install numpy

but it said:

但它说:

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

so apparently it was still there. I removed the contents of that folder and then I simply did:

显然它还在那里。我删除了那个文件夹的内容,然后我就这么做了:

sudo pip install numpy

This worked like freaking magic. Now I have NumPy 1.8.0, SciPy 0.12.0, Matplotlib 1.2.1 installed and everything is running like it should.

这就像变魔术一样。现在,我已经安装了NumPy 1.8.0、SciPy 0.12.0、Matplotlib 1.2.1,并且一切都运行正常。