Issue
I'm trying to create new Python virtual environment, but I have problems with pip.
I want my virtual environment to run on Python 3.10, but my default system Python version is 3.9.5. So I downloaded Python 3.10 with
sudo apt-get install python3.10
and then i run
python3 -m virtualenv venv --python=python3.10
to create virtual environment.
The problem is, when I try to use pip I get an error:
Traceback (most recent call last):
File "/home/<my user name>/venv/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
I tried running
python -m ensurepip --upgrade
but got an error:
/home/pablo/venv/bin/python: No module named ensurepip
Also running whereis pip
shows, that there are some pips in the virtual environment.
pip: /usr/bin/pip /home/<my user name>/venv/bin/pip3.10 /home/<my user name>/venv/bin/pip /usr/share/man/man1/pip.1.gz
Also, when I create virtual environments with my default python interpreter, everything works perfectly fine.
Solution
I would recommend using pyenv with pyenv-virtualenv. In my experience it's just too much work to go manual. Sorry I know this is not a true answer, but having wasted hours and hours on similar issues, I feel like sharing )
Answered By - alexakarpov