No module named pip
See original GitHub issueOpening this ticket because I think it could help others. Also, not pipx
’s fault 👍!
My distribution recently updated Python from 3.7.x to 3.8.0. It broke every single package I had installed with pipx somehow, and pipx itself.
I was left with these kind of errors:
$ guessit "some string"
Traceback (most recent call last):
File "/home/pawamoy/.local/bin/guessit", line 5, in <module>
from guessit.__main__ import main
ModuleNotFoundError: No module named 'guessit'
$ pipx install guessit
Traceback (most recent call last):
File "/home/pawamoy/.local/bin/pipx", line 6, in <module>
from pipx.main import cli
ModuleNotFoundError: No module named 'pipx'
$ pip install --user pipx
$ pipx install guessit
'guessit' already seems to be installed. Not modifying existing installation in '/home/pawamoy/.local/pipx/venvs/guessit'. Pass '--force' to force installation.
$ pipx install guessit --force
Installing to existing directory '/home/pawamoy/.local/pipx/venvs/guessit'
/home/pawamoy/.local/pipx/venvs/guessit/bin/python: No module named pip
Not removing existing venv /home/pawamoy/.local/pipx/venvs/guessit because it was not created in this session
'/home/pawamoy/.local/pipx/venvs/guessit/bin/python -m pip install guessit -q' failed
$ guessit
Traceback (most recent call last):
File "/home/pawamoy/.local/bin/guessit", line 5, in <module>
from guessit.__main__ import main
ModuleNotFoundError: No module named 'guessit'
$ pipx uninstall guessit
uninstalled guessit! ✨ 🌟 ✨
$ pipx install guessit
/home/pawamoy/.local/pipx/venvs/guessit/bin/python: No module named pip
'/home/pawamoy/.local/pipx/venvs/guessit/bin/python -m pip install guessit -q' failed
Not sure what exactly was happening behind the scenes as it’s always hard to figure out with Python: there’s the system versions, with their respective site-packages, there’s pyenv and its own installed versions and shims, then there’s potentially multiple pipx (shims?) and a script in ~/.local/bin (which one is the first in PATH?)… very convoluted but usually working.
Solution
Well, I simply had to explicitly uninstall pipx from the old system Python version with python3.7 -m pip uninstall pipx
and then reinstall it with the new system Python version with python -m pip install --user pipx
, and reinstall all pipx packages.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:21 (5 by maintainers)
Top GitHub Comments
I had the same problem, but was not able to use Python 3.7 to uninstall pipx.
I resolved this by uninstalling pipx, deleting
~/.local/pipx
, and reinstalling pipx with the new version of Python.Removing
~/.local/pipx
and reinstalling pipx also worked for me! Thanks.