Freezing application-specific dependencies in Python, virtualenv and pip
Another easy way of doing this would be using the pipreqs. So what it basically does is it generates pip requirements.txt file based on imports of any project.

Install pipreqs
pip install pipreqs
Then pipreqs /path/to/project

You will have your requirements.txt file generated in your project path.
How can I have a clean virtualenv for my flask application that contains nothing else than the dependencies of application needs?
I am using Ubuntu and I have a Flask application and when I run command pip freeze > requirements.txt the requirements file gets unnecessary files also
This leads to a problem when uploading it on heroku.
How do I resolve this?