python - 在 Mac OS Catalina 上卸载所有 `pip` 包
问题描述
尝试在我的 Mac 上卸载所有pip
和软件包,但遇到以下主要与和. 我已经尝试过:pip3
OSError: [Errno 30] Read-only file system:
[Errno 1] Operation not permitted:
- 在禁用时使用
csrutil disable
和运行卸载命令csrutil
- 在禁用时尝试
sudo -H
卸载csrutil
这些是错误:
第一:SIP状态pip
以及pip3
信息
$ csrutil status
System Integrity Protection status: disabled.
$ pip list
zsh: command not found: pip
$ python -m pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Package Version
-------------------------------------- --------
altgraph 0.10.2
asn1crypto 0.24.0
backports-abc 0.5
bdist-mpkg 0.5.0
bonjour-py 0.3
cffi 1.12.2
...
...
xattr 0.6.4
$ python3 -m pip list
Package Version
---------- -------
pip 19.2.3
setuptools 50.3.2
wheel 0.35.1
第二:尝试使用卸载所有pip
软件包python -m pip freeze | xargs python -m pip uninstall -y
$ python -m pip freeze | xargs python -m pip uninstall -y
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling pyobjc-framework-AppleScriptObjC-2.5.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/cli/base_command.py", line 176, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/commands/uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_install.py", line 823, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_uninstall.py", line 268, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/utils/misc.py", line 303, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 322, in move
copytree(src, real_dst, symlinks=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 231, in copytree
raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/_metadata.pyc', '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/_metadata.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/_metadata.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/_metadata.py', '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/_metadata.py', "[Errno 1] Operation not permitted: '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/_metadata.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/__init__.py', '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/__init__.py', "[Errno 1] Operation not permitted: '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/__init__.pyc', '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/__init__.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC', '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC', "[Errno 1] Operation not permitted: '/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-temp-Udv2QQ/AppleScriptObjC'")]
再试sudo python -m pip freeze | xargs sudo python -m pip uninstall -y
一次sudo -H python -m pip freeze | xargs sudo -H python -m pip uninstall -y
$ sudo python -m pip freeze | xargs sudo python -m pip uninstall -y
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
The directory '/Users/.../Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling pyobjc-framework-AppleScriptObjC-2.5.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/cli/base_command.py", line 176, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/commands/uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_install.py", line 823, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_uninstall.py", line 268, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/utils/misc.py", line 303, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 323, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 275, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 273, in rmtree
os.remove(fullname)
OSError: [Errno 30] Read-only file system: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/_metadata.pyc'
$ sudo -H python -m pip freeze | xargs sudo -H python -m pip uninstall -y
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling pyobjc-framework-AppleScriptObjC-2.5.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/cli/base_command.py", line 176, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/commands/uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_install.py", line 823, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/req/req_uninstall.py", line 268, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-19.0.1-py2.7.egg/pip/_internal/utils/misc.py", line 303, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 323, in move
rmtree(src)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 275, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 273, in rmtree
os.remove(fullname)
OSError: [Errno 30] Read-only file system: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/AppleScriptObjC/_metadata.pyc'
此处在 Apple Stack 上对此进行了简要讨论:https ://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade/209583但侧重于安装问题。
解决方案
推荐阅读
- python - 使用逗号分隔符将具有特定值的列标题写入单独的列
- javascript - 具有 setTimeout 函数的算法的时间复杂度是多少?
- asynchronous - 如何在 saga 函数中调用一段时间后的动作?
- java - 有人可以解释一下这是如何为每个整数返回正确的布尔值的吗?
- python - 这会增加生成数的随机性吗?
- java - 项目可以在IDE中读取txt文件,但导出项目后无法正常工作
- java - 在进行密码重置之前比较当前密码 - Keycloak
- ms-access - MS Access - 带有 WhereCondition 提示参数/无效括号的 OpenReport
- r - 获取网络R中的友谊时间长度
- python - 我该如何阻止它消失?