Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip freeze for only project requirements

Tags:

python

pip

When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior.

I have, however, done something wrong as this now includes things like Django in projects that have no business with Django.

How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.

like image 816
ToothlessRebel Avatar asked Sep 04 '15 04:09

ToothlessRebel


People also ask

How do I freeze requirements for pip?

The most common command is pip freeze > requirements. txt , which records an environment's current package list into requirements. txt. If you want to install the dependencies in a virtual environment, create and activate that environment first, then use the Install from requirements.

Should I use pip freeze?

pip freeze might seem very useful initially but it can mess up your project because of the following reasons: It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements. txt file. It still misses out on the libraries that are not installed using pip.

How do I freeze pip without version?

All you need is to install pip-chill from PyPI and run pip-chill from your Python environment. If you are feeling adventurous and don't want to pin versions (or want to use pip-compile), you can use pip-chill --no-version and it'll give you the minimal requirements for your current environment.

Does pip freeze show dependencies?

Since pip freeze shows all dependencies as a flat list, finding out which are the top level packages and which packages do they depend on requires some effort. It's also tedious to resolve conflicting dependencies that could have been installed because older version of pip didn't have true dependency resolution [1].


1 Answers

pipreqs can save the day for a specific project. Just

pip install pipreqs #then pipreqs path/to/project 

Github Page

like image 97
unlockme Avatar answered Sep 24 '22 21:09

unlockme