Skip to main content

Automatically installs missing Python libraries when running your code.

Project description

AutoPyPack

AutoPyPack is a zero-config tool that automatically installs missing Python packages in your project — whether you're running a script, a notebook, or from the command line.

✨ Works as both a CLI tool, an importable module, and supports magic commands inside Jupyter notebooks.


🚀 Features

  • 📦 Automatically installs missing packages from import statements
  • 🧠 Smart mapping from import names to PyPI package names
  • 🛠️ Use it via CLI, Python, or inside Jupyter notebooks with %%autopypack magic
  • 🔍 Detects local modules and standard libraries — no false installs
  • 🧪 Includes dev tools for testing and linting

📦 Installation

Install from PyPI:

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 (auto-scans your script)

import AutoPyPack  # 👈 Automatically scans and installs packages

# Your usual imports
import numpy as np
import pandas as pd

Manual usage

import AutoPyPack

AutoPyPack.install()                        # Scan current directory
AutoPyPack.install("/path/to/project")      # Scan specific directory
AutoPyPack.scan_file("example.py")          # Scan a specific file

🧪 Method 2: Inside a Jupyter Notebook

Enable magic with a single import:

import AutoPyPack

Use it in a cell:

%%autopypack
import pandas as pd
import sklearn
print("All imported successfully!")

✨ AutoPyPack will:

  • Detect missing packages in that cell
  • Install them with pip
  • Execute the cell code

🖥️ Method 3: As a CLI tool

Install missing packages in your project

autopypack install
autopypack i  # Short form

List all external packages

autopypack list
autopypack l  # Short form

Options

  • --dir, -d: Target a specific directory (default: .)
  • --quiet, -q: Suppress detailed logs (useful for scripts)

Example: generate requirements.txt

autopypack list --quiet > requirements.txt

⚙️ How it works

  1. Scans .py or notebook cell for import statements
  2. Identifies unique modules
  3. Uses mappings.json to resolve correct package names
  4. Installs anything missing via pip
  5. Skips local modules and stdlib

🧪 Development Mode

Install dev tools:

pip install -e .  # Already includes pytest, black, flake8

Run tests:

pytest

🪪 License

MIT © Harsh Jaiswal


🔗 Links

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

autopypack-1.2.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autopypack-1.2.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file autopypack-1.2.0.tar.gz.

File metadata

  • Download URL: autopypack-1.2.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for autopypack-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ffd59cb9e1e2915e9b533f167a5a87bfc7652eae72bc6a4dcf7a7582b4d3d8df
MD5 4d6ddaeede295bbb3e49edcbc8282841
BLAKE2b-256 ad49f8d7ea7b0a60b2f0ef4774dc80804b77e8a8e9362112988219be4e0f659d

See more details on using hashes here.

File details

Details for the file autopypack-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: autopypack-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for autopypack-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b6aef0d9ceec4eff1a7acef831f4311ac41d95158b6ea2e56511d622cf404a
MD5 2f70bd8e511a24d63040e2c6d81a19be
BLAKE2b-256 6e0994d9931d8403cbd7d08794c3716fd5b245bf26e87d240005567f70b71a58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page