ModuleNotFoundError: No module named 'pip._vendor.six'
b-hahn opened this issue · 20 comments
Issue description
I installed pipenv on my Ubuntu 20 system using /usr/bin/pip3 install --user pipenv. When I try installing any package I get the following error:
➜ pipenv install requests
Installing requests...
Installing package: requests
Writing supplied requirement line to temporary file: 'requests'
Installing 'requests'
⠙ Installing requests...$ ['/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/bin/pip', 'install', '--verbose', '--upgrade', '--exists-action=i', '-r', '/tmp/pipenv-bq9czv9c-requirements/pipenv-3e94mp9s-requirement.txt', '-i', 'https://pypi.org/simple']
Using source directory: '/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/src'
Error: An error occurred while installing requests!
Error text:
Traceback (most recent call last):
File "/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/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/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.exceptions import CommandError
File "/home/ben/.local/share/virtualenvs/blockbuster-yhSJSr9y/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'
I can imagine this might be related to interference from pyenv. Simply trying to install the missing six package just tells me it's already installed. Thanks for any help!
Expected result
Installing packages works.
Actual result
See above.
Steps to replicate
This happens in an empty folder as well, i.e. doesn't seem related to any pipenv file of mine.
$ pipenv --support
Pipenv version: '2021.5.29'
Pipenv location: '/home/ben/.local/lib/python3.8/site-packages/pipenv'
Python location: '/usr/bin/python3'
Python installations found:
3.9.1
:/home/ben/.pyenv/versions/tf/bin/python3.9
3.9.1
:/home/ben/.pyenv/versions/d39/bin/python3.9
3.9.1
:/home/ben/.pyenv/versions/minerl/bin/python3.9
3.9.1
:/home/ben/.pyenv/versions/gen_coco/bin/python3.9
3.9.1
:/home/ben/.pyenv/versions/3.9.1/bin/python3.9
3.8.10
:/usr/bin/python3
3.8.10
:/usr/bin/python3.8
3.8.10
:/bin/python3
3.8.10
:/bin/python3.8
3.8.7
:/home/ben/.pyenv/versions/3.8.7/bin/python3
3.8.7
:/home/ben/.pyenv/versions/d38_pt12/bin/python3
3.8.7
:/home/ben/.pyenv/versions/d38/bin/python3
3.7.9
:/home/ben/.pyenv/versions/d37/bin/python3.7
3.7.9
:/home/ben/.pyenv/versions/3.7.9/bin/python3.7m
3.7.9
:/home/ben/.pyenv/versions/d37_pd/bin/python3.7
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.8.10',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '5.11.0-34-generic',
'platform_system': 'Linux',
'platform_version': '#36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021',
'python_full_version': '3.8.10',
'python_version': '3.8',
'sys_platform': 'linux'}
System environment variables:
LC_TERMINAL
LC_CTYPE
LC_TERMINAL_VERSION
USER
LOGNAME
HOME
PATH
SHELL
TERM
SSH_AUTH_SOCK
XDG_SESSION_ID
XDG_RUNTIME_DIR
DBUS_SESSION_BUS_ADDRESS
XDG_SESSION_TYPE
XDG_SESSION_CLASS
MOTD_SHOWN
LANG
LC_NUMERIC
LC_TIME
LC_MONETARY
LC_PAPER
LC_NAME
LC_ADDRESS
LC_TELEPHONE
LC_MEASUREMENT
LC_IDENTIFICATION
SSH_CLIENT
SSH_CONNECTION
SSH_TTY
SHLVL
PWD
OLDPWD
ZSH
PAGER
LESS
LSCOLORS
LS_COLORS
PYENV_SHELL
PYENV_VIRTUALENV_INIT
_
PIP_DISABLE_PIP_VERSION_CHECK
PYTHONDONTWRITEBYTECODE
PIP_SHIMS_BASE_MODULE
PIP_PYTHON_PATH
PYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/home/ben/.cargo/bin:/usr/local/bin:/home/ben/.npm-global/bin:/home/ben/.pyenv/plugins/pyenv-virtualenv/shims:/home/ben/.pyenv/shims:/home/ben/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ben/.local/bin
SHELL
:/bin/zsh
LANG
:en_US.UTF-8
PWD
:/home/ben/devel/adv/test_folder
Contents of Pipfile
('/media/ben/data/devel/test_folder/Pipfile'):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.9"
I run into this error when I try use a python version other than the system version installed with pyenv
Environment
Windows 10 Home Edition
Windows Subsytem for Linux 2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ pipenv --version
pipenv, version 11.9.0
~$ pyenv --version
pyenv 2.1.0-7-g88c34049
$ pyenv versions
system
3.10.0
* 3.9.7 (set by /home/tpost/.pyenv/version)
Steps to recreate
$ pipenv --python 3.9
Creating a virtualenv for this project…
Using /home/tpost/.pyenv/versions/3.9.7/bin/python3.9 (3.9.7) to create virtualenv…
⠋created virtual environment CPython3.9.7.final.0-64 in 111ms
creator CPython3Posix(dest=/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/tpost/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
$ pipenv install django~=3.2.8
Installing django~=3.2.8…
⠙
Error: An error occurred while installing django~=3.2.8!
Traceback (most recent call last):
File "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/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 "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.exceptions import CommandError
File "/home/tpost/.local/share/virtualenvs/pages-_KdHKH5P/lib/python3.9/site-packages/pip/_internal/exceptions.py", line 10, in <module>
from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
However works fine with the system version, which is 3.8.10
currently.
After some investigation this appears to be an issue with the pip
installation on Debian based systems (Such as Ubuntu) which explains why I could not recreate the issue on my macbook.
On my WSL2 Ubuntu install:
$ virtualenv -p /home/tpost/.pyenv/shims/python ~/.virtualenvs/pages_env
$ source ~/.virtualenvs/pages_env/bin/activate
(pages_env) $ pip
Traceback (most recent call last):
File "/home/tpost/.virtualenvs/pages_env/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/home/tpost/.virtualenvs/pages_env/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/tpost/.virtualenvs/pages_env/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/tpost/.virtualenvs/pages_env/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/tpost/.virtualenvs/pages_env/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.exceptions import CommandError
File "/home/tpost/.virtualenvs/pages_env/lib/python3.10/site-packages/pip/_internal/exceptions.py", line 10, in <module>
from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
So this is not a pipenv
issue.
Ok I figured it out for my issue.
I did not have pipenv
installed for the version of python I was using
$ pyenv global 3.10.0
$ pip install pipenv
Solves this issue for me.
I'm also having this issue, but I don't want to use the system version of python. I'm using pipenv and pyenv precisely to lock in things like which version of python. This is infuriating. How do we get past this bug? Is there a better installation of pip? Does it have something to do with not getting pipenv to point to the correct pip?
Update on my end. I had a system-level install of pipenv, and I found in the pipenv documentation that that should be avoided. After I followed the instructions to just have a user-level install with pip install --user pipenv
and adding it to the path the way the documentation says to do so, it worked.
I had to install it through pipx
to have it work :
python3 -m pip install --user pipx
pipx install pipenv
Works with pyenv and works also with asdf
I get the exact same error but with PYPY, kindly asking for some help over here, any suggestions welcome. For the lack of identical threads about pypy on the web, I created a separate stack question:
I use an old version virtualenv ( 15.1.0 ), it became OK, so I think it is a bug of virtualenv.
It should have something to do with the redistributed version of pip on debian systems. So basically don't install pipenv into the global, use a tool like pipx
should work
Thought this is not strictly related to pipenv
it may help others with the same issue, and/or help with a better context for the problem:
- Installing
asdf
and the Python version
# Install Python plugin for asdf:
$: asdf plugin-add python
# List all available Python interpreters:
$: asdf list-all python
# Install the Python interpreters that you need:
$: asdf install python 3.10.1
-
Activate Python 3.10 in the local folder
Assuming the project folder is something like
$HOME/my-project
,
$: cd $HOME/my-project
# Define the local (project) version:
# (this creates a file .tool-versions in the current directory.)
$: asdf local python 3.10.1
- Check that were are using Python 3.10
$: python --version
Python 3.10.1
-
NOW create the Virtualenv, using
venv
(NOT virtualenv).Asumming the Virtualenv folder will be
ve3101
:
$: python -m venv ve3101
- Go back to the Python system version (just to be sure we will be using
the Virtualenv Python when activated)
$: asdf local python system
# Check it
$: python
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
- Activate the Virtualenv and check we are now running Python 3.10
$:. ve3101/bin/activate
(ve3101) $:python
Python 3.10.1 (main, Dec 7 2021, 13:45:06) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
- Now
pip
is running without problems
(ve3101) $:pip install flask
Collecting flask
Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
... etc ...
Hope it helps.
This thread feels informative, but is there an action item here or should we close it? I see where the install is described more in the documentation here: https://pipenv.pypa.io/en/latest/install/#installing-pipenv than in the README.md.
for ASDF users, that what helped me:
Recreate the shims for the desired Python version, then try again.
↪ asdf update
↪ asdf reshim python 3.6.6
↪ pipenv --python 3.6.6
Creating a virtualenv for this project…
Had the same issue as well. New installation of python 3.10.2 on ubuntu 20. Created a virtualenv the way I normally would virtualenv -p python3.10 env
but then ran into this exact issue trying to install a library via pip. The solution was to delete the newly created virtualenv and then recreate using the venv module in python3.10.2 thus
rm -r env
python3.10.2 -m venv env
I ran into this problem after installing python 3.9.10 from source, then created a virtualenv using it, but couldn't install any packages but instead got this ``ModuleNotFoundError: No module named 'pip._vendor.six'
I solved it by running this command:
curl -sS https://bootstrap.pypa.io/get-pip.py | ~/.local3910/bin/python3
note here ~/.local3910/bin/python3
is the full installation path for the python i installed. I was installing 3.9 alongside 3.8. Instructions for installing are here
I also had to recreate the virtualenv.
Hope this helps someone
On Ubuntu 20.04 LTS running rm -rf ~/.local/share/virtualenvs
fixed it on my case which cleans up "dangling virtualenv from previous version" as suggested on Ubuntu bug tracker https://bugs.launchpad.net/ubuntu/+source/pipenv/+bug/1885609. Did pipenv
installation through pipx
also earlier that was installed by pyenv
managed pip
(Python 3.9.11) but that didn't solve it by itself.
I am still experiencing this dependency hell:
- I have used pyenv to install a fresh 3.9.13 python version
- I have upgraded to the latest version of pip
- I have deleted virtualenv
There appears to be no simple way to either (a) install bundled version of pip or (b) have pip find site package "six" rather than look for bundled package.
I am running Ubuntu 20.04.4 LTS and python 3.9.13
@truekonrads Could you try the new version of pipenv that leans more exclusively on the vendor'd pip and not the user installed version. It just released, pipenv==2022.8.5
Eniveronment
Docker: 20.10.22
Image: nvidia/cuda:11.4.2-cudnn8-runtime-ubuntu20.04
Error found version
11.9.0 (use apt installed)
Solution
Turn to use pip install pipenv
@matteius Hi, I am trying to use docker to build an environment, and I chose to use apt to install pipenv, like this:apt-get install pipenv -y
and when I use pipenv to install package, it shows the error ModuleNotFoundError: No module named 'pip._vendor.six'
.
And when I turn to use pip install pipenv
at the build stage, it can work perfectly, so I think the problem is the current version of pipenv in apt.
Apt hasn't updated pipenv in a long time, please use pypi and pip to install.
I follow the Installation in the official README.md.
Can the apt install option be removed?
Thanks for your reply so fast😁