Programming
How To Generate The Requirements Of Your Python Project Based On Your Imports
How to add only the imported libraries to the requirements.txt files
We have provided many tutorials on how to generate the requirements.txt for your python project without environments, how to work with Conda environments, how to work with VS Code and Virtual Environments and so on. Today, we will provide an alternative way to get the requirement.txt file by including only the library that we have used, in other words, only the libraries that we have imported. We will provide two approaches, the first one is when we work with .py files and the second one when we work with Jupyter notebooks.
Working with .py files
Let’s assume that we work on the project, called “pipreqs_example“, where there is our .py file containing the code of the project. In order to make it reproducible, we would like to generate the “requirements.txt” file but ONLY for the used libraries. We can easily achieve that by using…