I have a fresh install of Ubuntu 24.04. I added pip with the usual sudo apt install python3-pip
, and went to install some packages, but got the error: externally-managed-environment. This was all quite new to me, so I did some reading about venv
. Using PyCharm, I attached a virtual environment to my Python project at /home/colin/Dropbox/codebase/Python
. All seems to be going well so far. I opened up a terminal and ran:
source /home/colin/Dropbox/codebase/Python/venv/bin/activate
and now I'm in the virtual environment. Next I try to install a package with either:
pip install requestspython3 -m pip install requests
In both cases I get ModuleNotFoundError: No module named 'pip'
. Okay, fair enough, my previous install of pip was for the system, and isn't visible in the virtual environment. So I try to install pip while in the venv:
sudo apt install python3-pip
and get:
python3-pip is already the newest version (24.0+dfsg-1ubuntu1).0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Huh. Okay. I'm still in the venv, and try:
which pip
and it returns:
/home/colin/Dropbox/Codebase/Python/venv/bin/pip
So what am I doing wrong here? Why can't I install packages with pip in my venv? It might be worth adding that I was following instructions from here for all this, but it doesn't mention this issue.