Getting an error with pip3 : ModuleNotFoundError: No module named 'pip._vendor.packaging.__about__'

Viewed 6210

Whenever I try using pip3 or anything that contains pip3, I get the following error:

ModuleNotFoundError: No module named 'pip._vendor.packaging.__about__' pops up.

I used it to install opencv and used opencv for multiple projects yesterday. I have no idea why the error popped up today.

Here is my code:

kaushiksankar@Kaushiks-MacBook-Pro ~ % pip3 install opencv-python
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 17, in <module>
    from pip._internal.utils.deprecation import DEPRECATION_MSG_PREFIX
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/utils/deprecation.py", line 13, in <module>
    from pip._vendor.packaging.version import parse
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/packaging/__init__.py", line 6, in <module>
    from .__about__ import (
ModuleNotFoundError: No module named 'pip._vendor.packaging.__about__'

I am using MacOS.

I cannot find the version of pip by any method. pip command cannot be used, hence used pip3.

1 Answers

Download the get-pip.py file and store it in the same directory as python is installed. Or use the following command to download pip directly,

wget https://bootstrap.pypa.io/get-pip.py

Now execute the downloaded file using the command below:

python3 get-pip.py

One can easily verify if pip has been installed correctly by performing a version check. Just go to the command line and execute the following command:

pip3 --version

After that, you can install your package:

pip3 install package_name
Related