Generate requirements.txt for Python projects, using an AI to resolve complex and ambiguous dependencies.
Project description
AI-Reqs: The Intelligent requirements.txt Generator
Tired of messy requirements.txt files? Frustrated that tools like pipreqs fail on your complex python projects and Jupyter Notebooks?
ai-reqs is a next-generation dependency scanner for Python that uses the power of Google's Gemini AI to solve the problems other tools can't. It intelligently scans your project, including .py files and .ipynb notebooks, and generates a clean, accurate requirements.txt file.
Why is ai-reqs better?
| Feature | pipreqs / pipreqsnb |
ai-reqs (This Tool) |
|---|---|---|
| Notebook Support | Often fails or requires a separate fork (pipreqsnb). |
✅ Yes, built-in. |
| Dependency Resolution | Uses a static, internal list of common packages. | 🧠 AI-Powered. Uses Gemini to resolve even the most obscure or confusing imports (cv2 -> opencv-python, PIL -> Pillow). |
| Robustness | Can crash on files with non-standard characters. | ✅ Handles encoding errors gracefully. |
| Future-Proof | Needs to be updated manually for new packages. | 🚀 Always up-to-date. The AI can identify new packages as they are released. |
Installation
pip install ai-reqs
Quick Start
-
Get a Gemini API Key:
- Go to Google AI Studio and create an API key.
-
Set the API Key (Optional): You can either set it as an environment variable (recommended) or pass it as an argument. On macOS / Linux:
# Recommended: Set as an environment variable export GEMINI_API_KEY="YOUR_API_KEY_HERE"
On Windows:
# Recommended: Set as an environment variable set GEMINI_API_KEY="YOUR_API_KEY_HERE"
-
Run
ai-reqs: Navigate to your project's root directory in your terminal and run the command:ai-reqs
Alternatively, you can pass the key directly as an argument (avoiding step 2):
ai-reqs --api-key YOUR_API_KEY
That's it! A clean
requirements.txtwill be generated in your project directory.
Usage
The command-line interface is simple and straightforward.
Usage
usage: ai-reqs [-h] [--path PATH] [--api-key API_KEY]
Generate a requirements.txt file for a Python project using AI for dependency resolution.
options:
-h, --help show this help message and exit
--path PATH The path to the project directory to scan. Defaults to
the current directory.
--api-key API_KEY Your Gemini API key. Can also be set via the
GEMINI_API_KEY environment variable.
How It Works
The tool scans all Python scripts and Jupyter Notebooks in your project to find all import statements. It then uses a hybrid approach to find the correct package for each import:
- It first checks your local Python environment's metadata.
- For any import it can't resolve locally (like
sklearnorcv2, which have different package names), it queries the Gemini API to get the correctpippackage name. - Finally, it generates a
requirements.txtfile with the correct package names and their currently installed versions.
Contributing
Contributions are welcome! Please feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_reqs-0.1.1.tar.gz.
File metadata
- Download URL: ai_reqs-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4758cf45888b4558192324e4c5cdc1f1b5d8fdf52ff4d48b1c920fc0565fc8f
|
|
| MD5 |
64e5d24002a21c5966c592481c351f3e
|
|
| BLAKE2b-256 |
6548d959798d002baa300ba50aeb4f329854586307e12cde57d5fa8501c989fd
|
File details
Details for the file ai_reqs-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ai_reqs-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb6b3c69f31b5444264e1e78e44d2250687c21764cd16b6f4c16982c0e00746
|
|
| MD5 |
8da95cba95ff519aeeda28ed13ad1300
|
|
| BLAKE2b-256 |
1ce306bd8f19930a8155569e791cb8c30b30d2d9874e239f3d97bd26f0fa83e6
|