简体   繁体   中英

My Pip installation is broken and I don't know how to reinstall it [MAC/OSX]

So I was frustrated at my python install because it wasn't installing virtualenv and virtualenvwrapper properly and tried to uninstall everything to try to get a fresh start, but now pip is broken and I'm getting these errors:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==21.0.1', 'console_scripts', 'pip')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^

Is there any way to reinstall pip manually? The installation methods on the website don't work. Thanks!

If you want Pip for Python 2

Seems like you have pip 21.0.1, which does not support any Python 2 version . Probably, your pip is not broken, but unsupported for your Python. Maybe you will have to manually install a lower pip, like (use something like python -m ensurepip , or look for a get-pip.py script. See the reference here ).

If you expect Pip to run under Python 3

Maybe your problem is: you want to run pip with Python 3, but it is running on Python 2. I know two solutions for this:

  • apt-get install python-pip3 , and then replace the usage of pip with the pip3 command
  • python3 -m pip . That way, you call pip with Python 3.

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