A lightweight Python module for requirements.txt generation. It efficiently extracts imported modules and generates a requirements.txt file with module versions for .py and .ipynb files in a given directory. Simplify dependency management for your projects!
- 📦 Automatic Module Extraction: Scans
.pyand.ipynbfiles in a directory to find all imported modules. - 🔍 Version Detection: Fetches installed versions of imported modules (maps common aliases to official package names). It also gives the option to includes fetch
source python versiontoo. - 📝 Requirements Generation: Creates a
requirements.txtfile with all extracted dependencies and the current Python version.
Clone this repository and install the requirements.
pip install pyreqifyTo use the pyreqify function and automatically create a requirements.txt file:
- Place all
.pyand.ipynbfiles in a folder (e.g.,project). - Run the function to generate a
requirements.txtin the current directory with all extracted dependencies.
pyreqify <source_folder> <destination folder> --include-source-pyversion
scikit-learn==1.5.1
keras==3.6.0
numpy==2.0.1
pandas==2.2.2
open3d==0.16.1
webcolors==24.8.0
nbformat==5.10.4
matplotlib==3.9.1
typing==3.7.4.3
torch==2.2.2
python==3.10.14
Example 1: Generate requirements.txt in the current working folder without the Python version.
pyreqify ~/Workspace/project .Example 2: Generate requirements.txt in the deploy folder, including the Python module versions and Python version in the file.
pyreqify ~/Workspace/project ~/Workspace/project/deploy --include-module-version --include-source-pyversion