我正在运行Ubuntu 12.04,默认情况下是NumPy 1.6.0
(我已经安装了,,Python 2.7.3
。作为对这个问题polyfit() got an unexpected keyword argument 'w'的回答的结果,我需要升级它。
我从here下载了版本.tar.gz
的{{1}}包,将其解压缩,移到文件夹中并运行命令:
1.8.0
如user guide和此问题中所述:Building NumPy 1.7.1 on Ubuntu。
这导致python setup.py build --fcompiler=gnu95
python setup.py install --user
中不再加载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
时,也发生了同样的情况。
我尝试删除1.7.1
:
numpy
还删除了sudo apt-get remove python-numpy
和matplotlib
。所以我尝试用以下方法重新安装它们:
scipy
但是失败并出现错误:
sudo apt-get install python-numpy python-scipy python-matplotlib
现在我没有运行python,我甚至不知道如何回到以前的稳定版本。所以问题是:我可以在我的系统中安装至少版本 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
,如果没有,我该如何回到正常工作的1.7.1
版本?感谢。
答案 0 :(得分:50)
sudo pip install numpy --upgrade
会以稍微减少的努力做同样的事情。
答案 1 :(得分: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
,一切都在运行。