无法卸载 pip 包
Cannot uninstall a pip package
我正在尝试卸载 numpy
,但出现权限错误:
(base) tfovid@tfovid-t777s:~/codebase$ pip uninstall numpy
Found existing installation: numpy 1.19.5
Uninstalling numpy-1.19.5:
Would remove:
/usr/bin/f2py3
/usr/bin/f2py3.9
/usr/lib/python3/dist-packages/numpy
/usr/lib/python3/dist-packages/numpy-1.19.5.egg-info
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.9/shutil.py", line 806, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/bin/f2py3' -> '/tmp/pip-uninstall-mzc7w25e/f2py3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
status = self.run(options, args)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 85, in run
uninstall_pathset = req.uninstall(
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 672, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 386, in remove
moved.stash(path)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 275, in stash
renames(path, new_path)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 324, in renames
shutil.move(old, new)
File "/usr/lib/python3.9/shutil.py", line 821, in move
os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/bin/f2py3'
我以为 sudo 特权可以解决它,但无济于事:
(base) tfovid@tfovid-t777s:~/codebase$ sudo pip uninstall numpy
[sudo] password for tfovid:
Found existing installation: numpy 1.19.5
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'numpy'. No files were found to uninstall.
(base) tfovid@tfovid-t777s:~/codebase$ sudo apt remove python-numpy
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python-numpy
这可能是什么原因以及如何解决?
我发现我必须指定 Python 3,所以 sudo apt remove python3-numpy
结束了工作。
我正在尝试卸载 numpy
,但出现权限错误:
(base) tfovid@tfovid-t777s:~/codebase$ pip uninstall numpy
Found existing installation: numpy 1.19.5
Uninstalling numpy-1.19.5:
Would remove:
/usr/bin/f2py3
/usr/bin/f2py3.9
/usr/lib/python3/dist-packages/numpy
/usr/lib/python3/dist-packages/numpy-1.19.5.egg-info
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.9/shutil.py", line 806, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/bin/f2py3' -> '/tmp/pip-uninstall-mzc7w25e/f2py3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
status = self.run(options, args)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 85, in run
uninstall_pathset = req.uninstall(
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 672, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 386, in remove
moved.stash(path)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 275, in stash
renames(path, new_path)
File "/home/tfovid/.local/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 324, in renames
shutil.move(old, new)
File "/usr/lib/python3.9/shutil.py", line 821, in move
os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/bin/f2py3'
我以为 sudo 特权可以解决它,但无济于事:
(base) tfovid@tfovid-t777s:~/codebase$ sudo pip uninstall numpy
[sudo] password for tfovid:
Found existing installation: numpy 1.19.5
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'numpy'. No files were found to uninstall.
(base) tfovid@tfovid-t777s:~/codebase$ sudo apt remove python-numpy
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python-numpy
这可能是什么原因以及如何解决?
我发现我必须指定 Python 3,所以 sudo apt remove python3-numpy
结束了工作。