简体   繁体   中英

PIP --upgrade not working on Python 3.8.2

I do have Python version 3.8.2 and an outdated version of PIP. I am using a Mac, and when I try to upgrade PIP by doing pip install --upgrade pip I'm getting this error message:

➜  ~ pip install --upgrade pip
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
    @_call_aside
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
    f(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==18.0' distribution was not found and is required by the application
➜  ~ ```

You will have to reinstall pip manually by following the steps here described.

  1. Donwload get-pip.py
  2. Run python get-pip.py in the folder you downloaded the python script to.
  3. Then, you can use pip normally.

pip runs the 2.7 pip. Look at the traceback. pip3 runs a 3.x pip, and if 3.8 is the only one, 3.8. python3 -m pip will run some 3.x pip and python3.8 -m pip will only run 3.8 pip. I recommend that you first upgrade to 3.8.7. I forget whether the python.org installer has an option to upgrade pip with it. If not,

python3.8 -m pip install --upgrade pip

should work (I just ran it). If not

python3.8 -m ensurepip

should install a recent pip which can be upgraded.

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