Home > Net >  Django pip freeze > requirements.txt not getting the exact packages installed in the virtual env
Django pip freeze > requirements.txt not getting the exact packages installed in the virtual env

Time:12-27

Django pip freeze > requirements.txt not getting the exact packages installed in the virtual env rather it's getting all the packages i have ever installed and it's kinda not what i exactly wants, let me show some image of whats happening

enter image description here

there are still more packages below, please what can i do

CodePudding user response:

Whenever you do

pip freeze

It prints out all the installed packages. May be you are confusing with packages installed as dependency of manually installed packages. For example if you install Fastapi, it will also install jinja2 I can't think of any case where you want packages installed by you and not their dependencies. Its not a problem at all.

On the other hand if its actually giving you all the packages ever installed, it means you have installed all your packages in the same environment always. You should use different environments for each of your project (sometimes even more than one for a single project). In this case, create another virtual environment, install requirements and then again use pip freeze. Steps below.

python3 -m venv venv
source venv/bin/activate
pip install {required packages}
pip freeze > requirements.txt
  • Related