Long story short, numpy gave me error when I was importing matplotlib, so I wanted to pip uninstall numpy
and reinstall it. but failed to fully uninstall numpy.
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/tmp/ipykernel_26902/2971697587.py in <module>
----> 1 import matplotlib
~/.local/lib/python3.7/site-packages/matplotlib/__init__.py in <module>
105 # cbook must import matplotlib only within function
106 # definitions, so it is safe to import from it here.
--> 107 from . import _api, cbook, docstring, rcsetup
108 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
109 from matplotlib.cbook import mplDeprecation # deprecated
~/.local/lib/python3.7/site-packages/matplotlib/rcsetup.py in <module>
24 from matplotlib import _api, animation, cbook
25 from matplotlib.cbook import ls_mapper
---> 26 from matplotlib.colors import Colormap, is_color_like
27 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
28 from matplotlib._enums import JoinStyle, CapStyle
~/.local/lib/python3.7/site-packages/matplotlib/colors.py in <module>
80 import matplotlib as mpl
81 import numpy as np
---> 82 from matplotlib import _api, cbook, scale
83 from ._color_data import BASE_COLORS, TABLEAU_COLORS, CSS4_COLORS, XKCD_COLORS
84
~/.local/lib/python3.7/site-packages/matplotlib/scale.py in <module>
16 import matplotlib as mpl
17 from matplotlib import _api, docstring
---> 18 from matplotlib.ticker import (
19 NullFormatter, ScalarFormatter, LogFormatterSciNotation, LogitFormatter,
20 NullLocator, LogLocator, AutoLocator, AutoMinorLocator,
~/.local/lib/python3.7/site-packages/matplotlib/ticker.py in <module>
177 import matplotlib as mpl
178 from matplotlib import _api, cbook
--> 179 from matplotlib import transforms as mtransforms
180
181 _log = logging.getLogger(__name__)
~/.local/lib/python3.7/site-packages/matplotlib/transforms.py in <module>
44
45 from matplotlib import _api
---> 46 from matplotlib._path import (
47 affine_transform, count_bboxes_overlapping_bbox, update_path_extents)
48 from .path import Path
ImportError: numpy.core.multiarray failed to import
I decided to uninstall and reinstall after the solutions found online doesn't work. (ImportError: numpy.core.multiarray failed to import)
pi@raspberrypi:~ $ pip uninstall numpy
Uninstalling numpy-1.16.6:
Would remove:
/home/pi/.local/bin/f2py
/home/pi/.local/bin/f2py2
/home/pi/.local/bin/f2py2.7
/home/pi/.local/lib/python2.7/site-packages/numpy-1.16.6.dist-info/*
/home/pi/.local/lib/python2.7/site-packages/numpy/*
Proceed (y/n)? y
Successfully uninstalled numpy-1.16.6
pi@raspberrypi:~ $ pip install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /usr/lib/python2.7/dist-packages (1.16.2)
supposing the first command already uninstalled numpy, why was requirement already satisfied?
I tried both pip uninstall
and pip3 uninstall
. then also went into python
and python3
to import the module as double check to see if the module is still installed. and the module was imported successfully.
also in the /usr/lib/python2.7/dist-packages
folder, numpy
was still there.
what is the problem?
how can I successfully uninstall and reinstall numpy?
Edit: I manually went into the dist-packages
directory of all versions of python, and rm
all the numpy related files. then reinstallation works.
CodePudding user response:
You can delete the files with this commands
rm -rf f2py
rm -rf 2py2
rm -rf numpy-1.16.6.dist-info/*
rm -rf numpy/*
or only:
rm f2py
rm 2py2
rm numpy-1.16.6.dist-info/*
rm numpy/*