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

🪪 License

MIT © Harsh Jaiswal


🔗 Links

PyPI Downloads

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.3.0.tar.gz (23.8 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.3.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autopypack-1.3.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for autopypack-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c7ba99040c26e99d6204ddaa3de1379c3c583ab4d8400a07a2e5af2dbfc1966f
MD5 4a3262a0e280d3b71152f0f968eaaeee
BLAKE2b-256 97b36b569bc9f9b3f9a63597a1764a7d0b48a6bd81d2ded0b395f3ec824a3bdf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: autopypack-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for autopypack-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a51fc5151906deedbd6d0ac8d7e878e9590d6cc4f1724ee184959a60c3893ce
MD5 150fb82aa47a693890ca8c1251c909a3
BLAKE2b-256 41537c55c6eed0460316cc53d50f276dfd448eb2f1e4ba9f6c1f2e5b733cfc10

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