I downgraded pip but can't upgrade it anymore

I downgraded my pip but I can’t upgrade anymore

I am making a game in python, it would automatically pip install the packages needed. but sometimes, the users pip is not up to date, and it won’t work(I am actually using Automator on mac) so in Automator I made it so it would pip install the latest pip version, to test it, I downgraded my pip version to 9.0.1 and now I can’t upgrade my pip version anymore, it would just leave an error saying:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
    from . import urllib3
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 35, in <module>
    from .connection import (
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/urllib3/connection.py", line 54, in <module>
    from ._collections import HTTPHeaderDict
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/urllib3/_collections.py", line 2, in <module>
    from collections import Mapping, MutableMapping
ImportError: cannot import name 'Mapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/collections/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/bin/pip", line 5, in <module>
    from pip import main
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'

I tried uninstalling pip but it just gave practically the same error

This is extremely far out of date.

If that’s why you wanted to use an older version of Pip - because newer versions broke an old way of doing it - the code was taking a fundamentally wrong approach. It is not intended for the Pip code to be imported and used as a library. Instead, use the subprocess standard library module to run a separate process to run Pip as an application.

I would say to try upgrading urllib3 first, but it seems unlikely that this would work, for obvious reasons.

I don’t know how you managed to downgrade Pip that far in 3.11. I don’t think it should have allowed you to try.

At this point I think you are better off reinstalling that Python version.

Try python -m ensurepip --upgrade. You may or may not need to run that as root (via sudo).

1 Like

Thanks for your help