Score:4

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

cn flag

I'm new to Ubuntu (20.04.2.0 LTS) and trying to get Python3.9.6 and Pip to work with Virtualenv.

I hope some of you experienced Ubuntu users can help me :)

I have no problem using default Python (3.8.10):

$ python3 -V Python 3.8.10

$ whereis python3 
/usr/bin/python3.8

$ pip3 -V 
pip 21.1.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

$ virtualenv env_python3.8 
created virtual environment CPython3.8.10.final.0-64 in 155ms

$ source env_python3.8/bin/activate

(env_python3.8) usagi@dev:~$ pip list 
Package Version
pip 20.0.2 pkg-resources 0.0.0
setuptools 44.0.0 wheel 0.34.2

(env_python3.8) usagi@dev:~$ pip install django 
Successfully installed asgiref-3.4.1 django-3.2.5 pytz-2021.1 sqlparse-0.4.1

(env_python3.8) usagi@dev:~$ pip list 
Package Version
asgiref 3.4.1
Django 3.2.5
pip 20.0.2 pkg-resources 0.0.0
pytz 2021.1 setuptools 44.0.0 sqlparse 0.4.1
wheel 0.34.2

These steps work without any problems, but if I do the same steps for Python3.9.6 (from source), it will not work:

$ python3.9 -V 
Python 3.9.6

$ whereis python3 
/usr/local/bin/python3.9

Guess this is one the problems, pip3 looking at Python3.8
$ pip3 -V 
pip 21.1.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

$ virtualenv -p /usr/local/bin/python3.9 env_python3.9 
created virtual environment CPython3.9.6.final.0-64 in 113ms

$ source env_python3.9/bin/activate

(env_python3.9) usagi@dev:~$ python -V 
Python 3.9.6

(env_python3.9) usagi@dev:~$ pip -V 
Traceback (most recent call last): File "/home/usagi
/env_python3.9/bin/pip", line 5, in from pip._internal.cli.main import main File "/home
/usagi/env_python3.9/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in 
from pip._internal.cli.autocompletion import autocomplete File "/home/usagi/env_python3.9
/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in from 
pip._internal.cli.main_parser import create_main_parser File "/home/usagi/env_python3.9
/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in from 
pip._internal.cli import cmdoptions File "/home/usagi/env_python3.9/lib/python3.9/site-
packages/pip/_internal/cli/cmdoptions.py", line 24, in from pip._internal.exceptions 
import CommandError File "/home/usagi/env_python3.9/lib/python3.9/site-packages
/pip/_internal/exceptions.py", line 10, in from pip._vendor.six import iteritems 
ModuleNotFoundError: No module named 'pip._vendor.six'

Tried to find information about the error but could not find a solution.

If any of you have had the same problem or recognize the problem and would like to help me, I am grateful for all the help I can get.

Best regards, /Mikael

ajgringo619 avatar
de flag
What does `python3.9 -m pip --version` return?
Usagi-Dev avatar
cn flag
Hello @ajgringo619, Thanks for the answer! The command returns: $ python3.9 -m pip --version /usr/local/bin/python3.9: No module named pip. There we probably have the problem. Next question: how do I install pip to /usr/local/bin/python3.9.
ajgringo619 avatar
de flag
How did you install python3.9?
Usagi-Dev avatar
cn flag
Hello again! I have installed Python3.9.6 from source.
Usagi-Dev avatar
cn flag
Tried installing it with sudo apt install Python 3.9 and it worked with virtualenv and pip. The problem then is that I can't choose exactly which Python version to install.
ajgringo619 avatar
de flag
If you decide to stick with the compiled version, just rebuild it with `--with-ensurepip=install` added to your `configure` command. I would not keep both versions.
Usagi-Dev avatar
cn flag
I reinstall my computer with Ubuntu. Installed Python with --with-ensurepip = install. Created a virtual environment with Virtualenv. Everything works fine until I use Pip and get the same error message again: `ModuleNotFoundError: No module named 'pip._vendor.six'`. Do you have any other idea what could be causing this?
Score:-1
de flag

I can't tell you why your compiled version is not working. Using the Ubuntu repo, you can get what you want and will get updated with the rest of the system:

sudo apt install python3.9 python3.9-venv

this will give you pip3.9 and the ability to create a virtual environment, something like this:

python3.9 -m venv $HOME/.venv/python3.9
Usagi-Dev avatar
cn flag
Thank you for taking the time to help me! Now everything works fine :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.