Search code examples
pythonpycharm

Requirements.txt from import statements?


I have cloned in a Pycharm project, a Github repo that does not have a requirements.txt file.

Rather than manually identifying all modules to pip install, is it possible to create a requirements.txt automatically, based on all import statements across the entire project?

I only know how to create one when I build the project myself, and the modules are already installed, using pip3 freeze > requirements.txt


Solution

  • You could try pipreqs (Generate pip requirements.txt file based on imports of any project): https://github.com/bndr/pipreqs

    pip install pipreqs