Skip to main content

Posts

Showing posts from May, 2020

Collect Python project dependencies

Sometimes we need to figure out dependencies of our Python project. I have been using the below two approaches to get it done: Using pipreqs If we want to collect all the dependencies and store them in a project-level 'requirement.txt' file, then pipreqs is an easy and simple solution. This library analyzes the import statements in the project to gather dependencies. First, we need to install pipreqs: pip install pipreqs In order to generate project-level requirement.txt file, run the below command: pipreqs /path/to/your/project/ requirements file would be saved as- ' /path/to/your/project/ requirements.txt ' To read about more advantages of pipreqs over pip freeze , read it from here Using pipdeptree     I have written a more detailed post about visual representation of python packages using 'pipdeptree' library in this blog . 'pipdeptree' provides more advanced options such as listing the dependencies in html format o