Ryan
Ryan

Reputation: 354

Possible to create a pip freeze requirements file off the libraries used in a single directory or file?

I use pip freeze > requirements.txt in my directory and it stores all the installed libraries on my machine. Is it possible to reduce this down to the libraries used in this directory or maybe just a single python file?

Upvotes: 1

Views: 738

Answers (1)

tomrom95
tomrom95

Reputation: 271

I think you have a few options. One is brute force use grep to find all the import statements in your files.

Another option, check out Snakefood: http://furius.ca/snakefood/doc/snakefood-doc.html

Simple tool you can use to print out python dependencies. Can be as simple as

sfood-imports yourfile.py

And you can extend it using the --unified flag to print out the set of unique libraries you need for the files in a directory.

Upvotes: 2

Related Questions