Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install -r requirements.txt is not working in venv

i have this weird problem with python venvs. If i activate the venv and try to install packages via pip install -r requirements.txt the packages are getting installed to the global python and not in the venv.

i am using python 3.11.2 on Debian Bookworm.

I've googled now 2 hours and tried everything including everything in pip installing in global site-packages instead of virtualenv and nothing helped. The path are correctly set,which pip gives me the path to the venv pip, there are no aliases, i created configfiles but nothing helped.

Then i tried to install a package without the -r requirements.txt e.g. pip install numpy that worked and the packages were installed inside the venv. So what's the problem of pip not installing packages with the -r parameter to the venv?

like image 241
BeRational Avatar asked Oct 25 '25 01:10

BeRational


1 Answers

This works for me:

python -m pip install -r requirements.txt

I think you error is occurring because pip is still referring to the global pip. This command refers to python's (the venv python) pip instead of the global python's pip.

like image 142
Ritvik S Avatar answered Oct 26 '25 14:10

Ritvik S