1

Trying to uninstall all pip and pip3 packages on my Mac, but am running into the following errors that are largely tied to OSError: [Errno 30] Read-only file system: and [Errno 1] Operation not permitted:. I have already tried:

  • using csrutil disable and running the uninstall commands while csrutil is disabled
  • trying sudo -H for the uninstalls while csrutil is disabled

These are the errors:

First: SIP status as well as pip and pip3 info

$ 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 

Second: trying to uninstall all pip packages using 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'")]

Trying again with sudo python -m pip freeze | xargs sudo python -m pip uninstall -y and 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'

This was discussed briefly on Apple Stack here: https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade/209583 but focuses on installation issues.

  • We have another StackOverflow thread where it is shown how to remove all packages installed by `pip`. I have given the link below. This should have gone in the comments but I don't have enough reputation to add a comment, so adding this as an answer. [What is the easiest way to remove all packages installed by pip?](https://stackoverflow.com/questions/11248073/what-is-the-easiest-way-to-remove-all-packages-installed-by-pip) – Rajtilak Bhattacharjee Feb 01 '21 at 06:10
  • 1
    I've already tried the solutions mentioned in that post. They do not address the SIP/Permissions failures. Also, the top-rated answer from that post is exactly the command I run in my shell that fails because of SIP/permissions issues. – BeginnersMindTruly Feb 01 '21 at 16:48
  • I have the same issues, as I can't remove the `wheel` package from the *global* installation. If I run the same commands with `sudo`, all of a sudden `pip` can't be found and `pip3` can't find the package... Just for context: I work on a Debian 10 system. – DavidHulsman Feb 04 '21 at 09:30

0 Answers0