長話短說,numpy 在我匯入 matplotlib 時給了我錯誤,所以我想pip uninstall numpy重新安裝它。但未能完全卸載 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
在網上找到的解決方案不起作用后,我決定卸載并重新安裝。(匯入錯誤:numpy.core.multiarray 匯入失敗)
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)
假設第一個命令已經卸載了numpy,為什么要求已經滿足?我嘗試了pip uninstall和pip3 uninstall。然后也進入python并python3匯入模塊作為仔細檢查以查看模塊是否仍然安裝。并且模塊匯入成功。也在/usr/lib/python2.7/dist-packages檔案夾里,numpy還在那里。問題是什么?如何成功卸載并重新安裝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.
uj5u.com熱心網友回復:
您可以使用此命令洗掉檔案
rm -rf f2py
rm -rf 2py2
rm -rf numpy-1.16.6.dist-info/*
rm -rf numpy/*
或僅:
rm f2py
rm 2py2
rm numpy-1.16.6.dist-info/*
rm numpy/*
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/334218.html
