首页 > 解决方案 > 在 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.

我怎样才能解决这个问题?

标签: matplotlibraspberry-piuninstallation

解决方案


如果您只想更新软件包,请尝试:

pip install --upgrade matplotlib

或对于特定版本:

pip install 'matplotlib>=3.1.1' --force-reinstall

如果你真的想删除它,你可以通过获取包安装地址来手动完成:

pip show matplotlib 

然后使用 rm -rf 手动删除它。

使用“setup.py”或任何环境安装软件包时,通常会导致此错误。这两种方法都没有留下足够的元数据让“pip 卸载”工作。


推荐阅读