简体   繁体   English

在Ubuntu 12.04上升级到numpy 1.8.0

[英]Upgrade to numpy 1.8.0 on Ubuntu 12.04

I'm running Ubuntu 12.04 which comes by default with NumPy 1.6.0 (I have, actually had , Python 2.7.3 installed). 我运行Ubuntu 12.04自带其默认使用NumPy 1.6.0 (我,其实是Python 2.7.3安装)。 As a result of the answer to this question polyfit() got an unexpected keyword argument 'w' , I need to upgrade it. 由于回答这个问题, 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: 我从这里下载了版本1.8.0.tar.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: 我尝试删除numpy

sudo apt-get remove python-numpy

which also removed matplotlib and scipy . 这也删除了matplotlibscipy So then I tried reinstalling them with: 那么我尝试重新安装它们:

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. 现在我没有运行python,我甚至不知道如何回到以前的稳定版本。 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? 所以问题是:我可以在我的系统中安装至少版本1.7.1 ,如果没有,我该如何回到工作的1.6.0版本? Thanks. 谢谢。

sudo pip install numpy --upgrade

只需稍微努力就可以做同样的事情。

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 ,一切运行都应该如此。

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

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