Automatically installs missing Python libraries when running your code.
Project description
AutoPyPack
AutoPyPack is a tool that automatically installs missing Python libraries in your projects.
Features
- Scans your Python project for imports
- Detects missing packages
- Automatically installs missing packages using pip
- Uses a comprehensive mapping of import names to package names
- Works as both a CLI tool and an importable module
Installation
pip install autopypack
Or install from source:
git clone https://github.com/harshRaj1601/AutoPyPack
cd autopypack
pip install -e .
Usage
Method 1: As an importable module (recommended)
Simply import AutoPyPack at the top of your Python file, and it will automatically scan for imports and install missing packages:
import AutoPyPack
# Rest of your code with imports
import numpy as np
import pandas as pd
# ...
You can also use AutoPyPack programmatically:
import AutoPyPack
# Scan and install packages for the current directory
AutoPyPack.install()
# Scan and install packages for a specific directory
AutoPyPack.install('/path/to/your/project')
# Scan and install packages for a specific file
AutoPyPack.scan_file('/path/to/your/file.py')
Method 2: Using the CLI
AutoPyPack provides two main commands through its CLI: install and list.
Install all missing packages in a project
autopypack install
Or use the short form:
autopypack i
Options:
--dir,-d: Specify a different directory to scan (default: current directory)--quiet,-q: Suppress informational output
Example:
autopypack install --dir /path/to/your/project --quiet
List all external packages used in a project
autopypack list
Or use the short form:
autopypack l
Options:
--dir,-d: Specify a different directory to scan (default: current directory)--quiet,-q: Only output package names without additional info (useful for generating requirements.txt)
Example:
# List packages with detailed output
autopypack list --dir /path/to/your/project
# Generate requirements.txt
autopypack list --quiet > requirements.txt
How it works
- AutoPyPack scans all Python files in your project
- It extracts all import statements and identifies unique module names
- It checks if each module is available in your Python environment
- For missing modules, it determines the correct package name using a mapping system
- It installs missing packages using pip
License
MIT
Project details
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 autopypack-1.0.1.tar.gz.
File metadata
- Download URL: autopypack-1.0.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f4676f25c5087cb97cbe0db7ba854fa42c1f50fa010a104fdd136e44c1dedb5
|
|
| MD5 |
b6aab372b547df36c8aa345e79c58f08
|
|
| BLAKE2b-256 |
f4b9a61b1111ba8f6467845270cb49ef2ae72430a729712539e7e49d93cc1834
|
File details
Details for the file autopypack-1.0.1-py3-none-any.whl.
File metadata
- Download URL: autopypack-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e71081eb8a478e975995b0f4b70dad6e578e5398db897494fc787e1de0455e28
|
|
| MD5 |
cd5fafc970bede2352de9bc8ab2e08fc
|
|
| BLAKE2b-256 |
3691a961e26e43877921d115177f14ed6ad0946cc9193c4b2079995c72ce2d1a
|