title: Uninstall all the packages installed using pip by a user on macOS High Sierra
body: <p>By mistake I installed packages in the global environment using pip. I was wondering if its a good idea to uninstall the already existing Python on the OS using the instructions provided <a href="https://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4">here</a>,  and re-install it using homebrew using the instructions provided <a href="https://apple.stackexchange.com/questions/284824/remove-and-reinstall-python-on-mac-can-i-trust-these-old-references">over here</a>? Or is there any way to get rid of all packages and their dependency I installed using pip.</p>
  <p>I'm using Python 2.7.10 on macOS High Sierra.
  EDIT: Problem with a suggested approach:</p>
  <p>As suggested by <a href="https://stackoverflow.com/users/7197281/cloc">CloC</a> in the comments section, I tried uninstalling all packages from global environment by typing</p>
  <pre><code>pip freeze &gt; to_delete.txt
  </code></pre>
  <p>and then</p>
  <pre><code>sudo -H pip uninstall -y -r to_delete.txt
  </code></pre>
  <p>However I got the following error in the terminal:</p>
  <pre><code>Exception:
  Traceback (most recent call last):
    File &quot;/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/basecommand.py&quot;, line 141, in main
      status = self.run(options, args)
    File &quot;/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/commands/uninstall.py&quot;, line 74, in run
      auto_confirm=options.yes, verbose=self.verbosity &gt; 0,
    File &quot;/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/req/req_install.py&quot;, line 864, in uninstall
      uninstalled_pathset.remove(auto_confirm, verbose)
    File &quot;/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/req/req_uninstall.py&quot;, line 221, in remove
      renames(path, new_path)
    File &quot;/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/pip/_internal/utils/misc.py&quot;, line 276, in renames
      shutil.move(old, new)
    File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py&quot;, line 299, in move
      copytree(src, real_dst, symlinks=True)
    File &quot;/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py&quot;, line 208, in copytree
      raise Error, errors
  Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py', '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py', &quot;[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib/dyld.py'&quot;), [...], &quot;[Errno 1] Operation not permitted: '/private/tmp/pip-uninstall-3QWFII/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/macholib'&quot;)]
  </code></pre>