pipenv: ModuleNotFoundError: No module named 'pip._vendor.six'

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"

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 20 (4 by maintainers)

Most upvoted comments

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.

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 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

Apt hasn’t updated pipenv in a long time, please use pypi and pip to install.

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

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.