Run any Python script with automatic environment setup, fast package resolution via uv, and reproducible lockfile generation
Project description
smartrun
Run any Python script in a clean, disposable virtual environment — automatically.
smartrun 🚀
Run Python and Jupyter files with zero setup, zero pollution. Just run it.
smartrun scans your script or notebook, detects the required third-party packages, creates (or reuses) an isolated environment, installs what’s missing — and runs your code.
✅ No more ModuleNotFoundError
✅ No more cluttered global site-packages
✅ Just clean, reproducible execution — every time
Features
- 🧪 Supports both
.pyand.ipynbfiles - 🔍 Automatically detects and resolves imports
- 🛠️ Uses
venvor fastuvenvironments (if available) - 📦 Installs only what's needed, only when needed
- 💡 Reuses environments smartly to save time
Installation
🔹 Basic usage
pip install smartrun
This includes support for:
- Running standard Python scripts
- Automatic environment setup
- Fast dependency resolution with uv
- Reproducible installs via pip-tools 🔹 With Jupyter notebook support If you want to run .ipynb notebook files using smartrun, install the optional jupyter dependencies:
pip install "smartrun[jupyter]"
🔹 Development install (optional) For contributors and development work, install with:
pip install "smartrun[dev,jupyter]"
Requires Python 3.10+
Usage
smartrun your_script.py
Notebook
smartrun your_notebook.ipynb
Example file that we want to run
#some_file.py
import numpy as np
import pandas as pd
from rich import print
df = pd.DataFrame(np.random.randn(5, 3), columns=list("ABC"))
print("Data:")
print(df, end="\n\n")
print("Column means:")
print(df.mean())
Create an environment
✅ Create an environment : Windows / macOS / Linux
smartrun env .venv
✅ Activate the environment: Windows
.venv\Scripts\activate
🐧 macOS/Linux
✅ Activate the environment: macOS/Linux ```bash source .venv/bin/activate ```🪟 Windows
✅ Activate the environment: Windows ```bash .venv\Scripts\activate ```🌸 Iris dataset analysis
```python # iris.py import seaborn as sns import pandas as pd import matplotlib.pyplot as plt # Load data df = sns.load_dataset('iris') # Show first few rows and summary print(df.head(), end="\n\n") print(df.describe(), end="\n\n") # Plot pairwise relationships sns.pairplot(df, hue='species') plt.savefig('iris_pairplot.png') ``` ```bash smartrun iris.py ```🐼 Titanic Dataset demo
```python # titanic.ipynb import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Load dataset from GitHub url = 'https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv' df = pd.read_csv(url) # Basic stats print(df[['Survived', 'Pclass', 'Sex']].groupby(['Pclass', 'Sex']).mean()) # Plot survival by class sns.countplot(data=df, x='Pclass', hue='Survived') plt.title('Survival Count by Passenger Class') plt.savefig('titanic_survival_by_class.png') print("Saved plot → titanic_survival_by_class.png") ``` ```bash smartrun titanic.ipynb ```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 smartrun-0.2.27.tar.gz.
File metadata
- Download URL: smartrun-0.2.27.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6598f5706bf31a809a07d9fd3c5cb51e6dfbb70817f8f9d5bc0014515411183a
|
|
| MD5 |
3c9834c7901a93a5ec2dd4d69a76448a
|
|
| BLAKE2b-256 |
0ce5ba8d198cf3b1209450370ef9921259c9a06e16fcf70d5edcfbb57fbea64f
|
File details
Details for the file smartrun-0.2.27-py3-none-any.whl.
File metadata
- Download URL: smartrun-0.2.27-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd0c412b11806739a465b0a253281baaf039e698c5384d28a785494872cea2d0
|
|
| MD5 |
478dc8678b2773885fb809bc440cf7a9
|
|
| BLAKE2b-256 |
e8f334b263ce42e1ad829fbaafb5296843b34cdbc7785873a9a234a8aafb7538
|