Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get directory package dependencies in python?

I am aware that pip freeze > requirements.txt exists, yet that that prints out my system packages, of which only a few my directory/ project needs.

I am not using a virtualenv so I'm pretty sure I can't print out local packages like that.

I also know that pipdeptree exsists but I also don't see how that solves my problem?

like image 572
girraiffe Avatar asked Sep 21 '25 00:09

girraiffe


1 Answers

I believe tools like the following could help:

  • pipreqs
  • pigar

As far as I can tell, these tools read the code in the directory and try to figure out the dependencies required based on the import statements they found in the code.

Related:

  • Dependencies auto discovery for Python setuptools?
  • pip's requirements.txt best practice
  • Automatically create requirements.txt
  • How to get the list of dependencies to be added to install_requires section in setup.py from a python lib
like image 130
sinoroc Avatar answered Sep 22 '25 15:09

sinoroc