pip3 not working; "ModuleNotFoundError"

Trying to install anything with
pip3
returns the following error:

$ pip3 install pandas
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_internal/cli/main.py", line 11, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_internal/build_env.py", line 15, in <module>
    from pip._vendor.packaging.requirements import Requirement
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_vendor/packaging/requirements.py", line 8, in <module>
    from ._parser import parse_requirement as _parse_requirement
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_vendor/packaging/_parser.py", line 12, in <module>
    from ._tokenizer import DEFAULT_RULES, Tokenizer
  File "/home/nilmethod/.local/lib/python3.12/site-packages/pip/_vendor/packaging/_tokenizer.py", line 8, in <module>
    from .specifiers import Specifier
ModuleNotFoundError: No module named 'pip._vendor.packaging.specifiers'


it looks like pip3 and python3 were installed with homebrew but I don't recall if this is the default. Running the system
pip
(from
~/.local/bin
) encounters this issue as well. I belive it was installed with the system python from
/usr/bin/python
.

How can I resolve this issue? Thanks!
Was this page helpful?