首页 > 解决方案 > 在 Mac OS Catalina 上卸载所有 `pip` 包

问题描述

尝试在我的 Mac 上卸载所有pip和软件包,但遇到以下主要与和. 我已经尝试过:pip3OSError: [Errno 30] Read-only file system:[Errno 1] Operation not permitted:

这些是错误:

第一: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但侧重于安装问题。

标签: pythonpipuninstallationmacos-catalina

解决方案


推荐阅读