简体   繁体   中英

How can I uninstall pip packages on my mac?

I am trying to run the following command to uninstall pip packages on my mac:

pip freeze | xargs sudo pip uninstall -y

(even with sudo -H flag, it doesn't work)

pip freeze gives me the following list of pip installed packages:
altgraph==0.10.2
bdist-mpkg==0.5.0
beautifulsoup4==4.5.3
bonjour-py==0.3
certifi==2017.11.5
chardet==3.0.4
cognitive-face==1.3.1
dill==0.2.7.1
Django==1.11.6
djangorestframework==3.7.1
filemapper==0.1.3
future==0.16.0
idna==2.6
inflection==0.3.1
lxml==3.7.2
macholib==1.5.1
matplotlib==1.3.1
modulegraph==0.10.4
more-itertools==4.0.1
ndg-httpsclient==0.4.3
ngrams==1.0.3
nltk==3.2.2
numpy==1.8.0rc1
py2app==0.7.3
pyasn1==0.4.2
pygame==1.9.3
pyobjc-core==2.5.1
pyobjc-framework-Accounts==2.5.1
pyobjc-framework-AddressBook==2.5.1
pyobjc-framework-AppleScriptKit==2.5.1
pyobjc-framework-AppleScriptObjC==2.5.1
pyobjc-framework-Automator==2.5.1
pyobjc-framework-CFNetwork==2.5.1
pyobjc-framework-Cocoa==2.5.1
pyobjc-framework-Collaboration==2.5.1
pyobjc-framework-CoreData==2.5.1
pyobjc-framework-CoreLocation==2.5.1
pyobjc-framework-CoreText==2.5.1
pyobjc-framework-DictionaryServices==2.5.1
pyobjc-framework-EventKit==2.5.1
pyobjc-framework-ExceptionHandling==2.5.1
pyobjc-framework-FSEvents==2.5.1
pyobjc-framework-InputMethodKit==2.5.1
pyobjc-framework-InstallerPlugins==2.5.1
pyobjc-framework-InstantMessage==2.5.1
pyobjc-framework-LatentSemanticMapping==2.5.1
pyobjc-framework-LaunchServices==2.5.1
pyobjc-framework-Message==2.5.1
pyobjc-framework-OpenDirectory==2.5.1
pyobjc-framework-PreferencePanes==2.5.1
pyobjc-framework-PubSub==2.5.1
pyobjc-framework-QTKit==2.5.1
pyobjc-framework-Quartz==2.5.1
pyobjc-framework-ScreenSaver==2.5.1
pyobjc-framework-ScriptingBridge==2.5.1
pyobjc-framework-SearchKit==2.5.1
pyobjc-framework-ServiceManagement==2.5.1
pyobjc-framework-Social==2.5.1
pyobjc-framework-SyncServices==2.5.1
pyobjc-framework-SystemConfiguration==2.5.1
pyobjc-framework-WebKit==2.5.1
pyOpenSSL==0.13.1
pyparsing==2.0.1
python-dateutil==1.5
pytz==2013.7
requests==2.18.4
scikit-learn==0.19.1
scipy==0.13.0b1
SimpleCV==1.3
six==1.4.1
sklearn==0.0
urllib3==1.22
xattr==0.6.4
zope.interface==4.1.1

Using pip freeze | xargs sudo pip uninstall -y pip freeze | xargs sudo pip uninstall -y , I get the following result:

Uninstalling altgraph-0.10.2:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/uninstall.py", line 76, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 346, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Dot.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/Graph.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphAlgo.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphStat.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/GraphUtil.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.py', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.py', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.pyc', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph/ObjectGraph.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph', '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph', "[Errno 1] Operation not permitted: '/tmp/pip-YANgl9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/altgraph'")]

It stops uninstalling at the very first package only, doesn't even move to other packages. I tried using pip uninstall <package-name> to uninstall packages individually, it still didn't work and gave the same sequence of error statements each time.
I am not aware where I am making a mistake. I want to reset all pip installed packages to start new and install the required packages from scratch.

Can anyone help me with this, please?

I tried to reproduce the error and I think you should pass the argument xargs -n 1 to mention the first block of each row. Otherwise try to check if it is not a problem specific to your package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM