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'
$ 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!
3 Replies
Linus Xu
Linus Xu3mo ago
Most likely it's just the paths from Homebrew Python conflicting with the system one Hmmm just checked that Homebrew pip should always quit with error: externally-managed-environment I would guess overriding that broke the paths Does pip without the 3 work? That should always be system pip
Zeglius
Zeglius3mo ago
brew unlink python should do
nilmethod
nilmethod3mo ago
I'll try both of those. My current fix was to delete the non-brew pip and use the get-pip.py script from the python docs to install it again. Thanks!
Want results from more Discord servers?
Add your server