matplotlib - 在 Raspberry Pi 上卸载 matplotlib 时出现权限错误
问题描述
我正在尝试卸载我的 Raspberry Pi 上的 NOOBS 安装附带的 matplotlib 3.0.2 版本,以便我可以安装更高版本。但是我遇到了权限错误使用..
python3 -m pip uninstall matplotlib
但是如果我在这个命令前面添加 sudo,它会返回说没有找到要卸载的文件。下面是运行这两个命令的屏幕截图...
pi@raspberrypi:~ $ python3 -m pip uninstall matplotlib
Uninstalling matplotlib-3.0.2:
Would remove:
/usr/lib/python3/dist-packages/matplotlib
/usr/lib/python3/dist-packages/matplotlib-3.0.2.egg-info
/usr/lib/python3/dist-packages/pylab.py
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.7/shutil.py", line 563, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/__pycache__/pylab.cpython-37.pyc' -> '/tmp/pip-uninstall-zxmluyqe/pylab.cpython-37.pyc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/commands/uninstall.py", line 79, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 755, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
moved.stash(path)
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
renames(path, new_path)
File "/home/pi/.local/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 338, in renames
shutil.move(old, new)
File "/usr/lib/python3.7/shutil.py", line 578, in move
os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/__pycache__/pylab.cpython-37.pyc'
pi@raspberrypi:~ $ sudo python3 -m pip uninstall matplotlib
Not uninstalling matplotlib at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'matplotlib'. No files were found to uninstall.
我怎样才能解决这个问题?
解决方案
如果您只想更新软件包,请尝试:
pip install --upgrade matplotlib
或对于特定版本:
pip install 'matplotlib>=3.1.1' --force-reinstall
如果你真的想删除它,你可以通过获取包安装地址来手动完成:
pip show matplotlib
然后使用 rm -rf 手动删除它。
使用“setup.py”或任何环境安装软件包时,通常会导致此错误。这两种方法都没有留下足够的元数据让“pip 卸载”工作。
推荐阅读
- c++ - 无法从 QT 中的 tableWidget 获取项目
- javascript - 无法读取 null 的属性(读取“getContext”)
- python - 你如何与熊猫进行分组,它对同一列中的值求和但被一组行数偏移
- rtsp - ONVIF:列出同一网络中 IP 摄像机的所有主机名
- java - 在 Android 中使用 api 将图像上传到 Imgur 时出错
- xml - 如何使用 XSLT 从 XML 中删除元素标记
- bootstrap-5 - 引导程序更大的图标
- javascript - Netsuite - REST API - 如何使用基于令牌的身份验证 (TBA) 创建新条目记录 - (在 Python 中)
- typescript - 是否有另一种方法可以在不使用通常的导入语句的情况下导入本地图像?
- node.js - 执行 Docker 命令“docker-compose up”时出现错误 - - “node-app-1 | /bin/sh: [npm,: not found”