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.
I downloaded the .tar.gz
package for the version 1.8.0
from here, unpacked it, moved inside the folder and run the commands:
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.
This resulted in NumPy
no longer loading in Spyder
, which now shows the error:
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
.
I tried removing numpy
with:
sudo apt-get remove python-numpy
which also removed matplotlib
and scipy
. 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. 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.
NumPy 1.22. 0 is a big release featuring the work of 153 contributors spread over 609 pull requests. The Python versions supported by this release are 3.8-3.10.
sudo pip install numpy --upgrade
will do the same thing with slightly less effort.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With