pipx: ModuleNotFoundError: No module named 'pip._vendor.six' when running "pipx install"
Describe the bug
I have installed a new Debian (unstable) system. On one of my installations pipx runs without problems. The newly installed system behaves differently and I do not know where to look.
How to reproduce
$ pipx install --verbose youtube-dl
pipx > (_package_name_from_spec:93): Determined package name: youtube-dl
pipx > (_package_name_from_spec:94): Package name determined in 0.0s
pipx > (run_subprocess:112): running /usr/bin/python3 -m venv --without-pip /home/kai/.local/pipx/venvs/youtube-dl
pipx > (run_subprocess:112): running /home/kai/.local/pipx/venvs/youtube-dl/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx > (run_subprocess:112): running /home/kai/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx > (run_subprocess:112): running /home/kai/.local/pipx/venvs/youtube-dl/bin/python --version
pipx > (run_subprocess:112): running /home/kai/.local/pipx/venvs/youtube-dl/bin/python -m pip install youtube-dl
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.exceptions import CommandError
File "/home/kai/.local/pipx/shared/lib/python3.8/site-packages/pip/_internal/exceptions.py", line 10, in <module>
from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
pipx > (install_package:189): '/home/kai/.local/pipx/venvs/youtube-dl/bin/python -m pip install youtube-dl' failed
pipx > (rmdir:18): removing directory /home/kai/.local/pipx/venvs/youtube-dl
Error installing youtube-dl.
If I run python3 from the command line I can import the module:
$ python3 -c "import pip._vendor.six"
$
I have no idea what could be different. I already checked the list of python3-* packages on both systems but that seems to be the same. Any idea what to look for or how to debug the issue?
Expected behavior
The package should be installed.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 34 (15 by maintainers)
Commits related to this issue
- Handle debundled pip._vendor, fixes #386 Some distrbutions (Debian, Redhat) break up pip's _vendor directory into its constituent wheels, in which case we want to ensure that the pth file we write in... — committed to ivanov/pipx by ivanov 4 years ago
- a pip in every virtual env, like the good ol' days This is a minimal change that also fixes #386 — committed to ivanov/pipx by ivanov 4 years ago
- Avoid Debian-patched pip in the shared venv Should fix #386. — committed to mgedmin/pipx by mgedmin 4 years ago
- Avoid Debian-patched pip in the shared venv Should fix #386. — committed to mgedmin/pipx by mgedmin 4 years ago
- Avoid Debian-patched pip in the shared venv Should fix #386. — committed to mgedmin/pipx by mgedmin 4 years ago
Just want to add that I had this problem when installed python3.9, migrating form 3.8. (not on debian) Installing 3.9 made my existing virtual envs not work, and I got this error. Completely removing
~/.local/pipx
, then reinstalling my pipx things solved the problem.Workaround for poor new Ubuntu 20.04 LTS users like little old me:
This installs the upstream version of pip 20.0.2 in the shared venv, instead of the patched Debian version of pip 20.0.2.
I imagine when upstream pip releases 20.0.3, this problem will go away on its own, because I expect pipx will keep pip upgraded, while Debian won’t.
Same on Ubuntu 20.04… So we cannot use pipx until Debian team update something? With Debian it can take a while, I’m not even sure my grand childrens will see it.
Thank you for the suggestion, that’s a good solution for anyone who is blocked at the moment. However one of the reasons I really liked pipsi and decided to pursue pipx was the idea that you could install things with as little hassle as possible. I was trying to ship an app with Python and my user instructions always felt so ridiculous (create a venv, install it there…). Even if one is not necessarily a Python developer they should be able to take advantage of the ecosystem. It’s unfortunate that there is still no good story around this, and requiring casual users who want to use a Python “app” to mess with pyenv is still too high a bar, IMO.
Given the large userbase of Debian/Ubuntu (I am one of them but I guess I haven’t been bit by this because I haven’t upgraded), this will impact a lot of people, so I think it’s worth it to build support into pipx to work around whatever they are doing.
Just an update that this issue (filed as Debian Bug #958764) has now been fixed by in the latest
python3-pip
package in Debian Unstable (Version: 20.1-1). The patch of interest for Debian derivatives entails switching to usingsys.base_prefix
in place ofsys.prefix
for the unbundling logic, see this commit.Just reported this as a bug in the Debian python3-pip package (#958764).
Same issue here when using
pyenv
andpipenv
:When preparing to use
pyenv
, I mistakenly includedpython3-dev
duringapt install
. This apparently installs a local version ofpip
which leads to a conflict of some kind when runningpipenv install ...
.I resolved the issue by removing
python3-dev
and installing the necessary packages separately:After cleaning this up I was able to run
pipenv install ..
as expected.Examine the pip in your pipx shared environment. If it looks like this:
Then that’s the one from Debian. The relevant code in the wheel for pip on PyPI looks like this:
I had the same issue to report here, and tracked it down to the fact that venv is passed the
--without-pip
flag. If I take that flag away (which is how the previous version of pipx that’s currently in Debian - 0.12.3.1- used to work) - then pipx and pip are all happy.This is because Debian patches pip and
On import of pip._vendor, a bunch of the wheel contents for these debundled dependencies get added to sys.path.
$ python3 -c "import sys; print(sys.path); import pip._vendor; print(sys.path)"
(Shameless plug)
I have a tool that strips with shell script shim thing, which hopefully makes it more approachable 🙂
https://github.com/uranusjr/pythonup-posix
Thanks for the advise. I’ve installed python rom the source code on my ubuntu 20.04.
I have updated with
sudo update-alternatives --config python3
Then I installed pipx with
sudo pip3 install pipx
And now when I try to install something
Do you have an idea what is missing here? Thanks for your help.
Yes, you can erase the dir and pipx will recreate it.
https://github.com/pipxproject/pipx/blob/master/src/pipx/shared_libs.py#L38 https://github.com/pipxproject/pipx/blob/master/src/pipx/shared_libs.py#L32
This looks like a problem with
pip
to me. For some reason pip is looking for a submodule that is not installed.I don’t think this is a pipx error, but looks to me like a problem with the pip installation on that system.