Run Python scripts using the local virtual environment without activating it
Project description
localpython
Run Python scripts using your local virtual environment — without activating it manually.
localpython is a simple cross-platform CLI tool that automatically detects your local .venv, venv, or env folder and uses its Python interpreter to run a script — just like a smart alias. It can also create virtual environments and install dependencies automatically.
Features
- Runs scripts using
.venv/Scripts/pythonorbin/python - No need to activate virtual environments manually
- Supports arguments, flags, and quoted paths
- Automatically searches parent directories with
-p - Creates virtual environments and installs dependencies with
--setup - Includes
--version,--which,--help
Installation
Install via pip:
pip install localpython
Usage
Basic
localpython script.py
Pass arguments to your script
localpython script.py --input file.json --debug true
Search in parent directories for a venv
localpython -p script.py --some arg
Show path to the interpreter
localpython --which
Show version
localpython --version
Create virtual environment and install dependencies
localpython --setup
This will:
- Check if a virtual environment already exists (and warn if it does)
- Create a
.venvdirectory in the current location - Automatically detect and install dependencies from common requirements files:
requirements.txt,req.txt,requirements-dev.txtrequirements-test.txt,dev-requirements.txt,reqs.txtpip-requirements.txt,requirements.pip
Example
Given a project:
myproject/
├── .venv/
├── script.py
And a command:
localpython script.py --run fast
This tool will automatically run:
./.venv/Scripts/python script.py --run fast
(Or the Unix equivalent if on Linux/Mac)
License
This project is licensed under the MIT License.
Author
Created by Yali Ach
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 localpython-0.2.0.tar.gz.
File metadata
- Download URL: localpython-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69c005a9e57a1c40a40d633c5dd5e8f84dcf22fd8a615fce442886db4ca1bebe
|
|
| MD5 |
02c8d41f15c9449564bcd70a60a5dd91
|
|
| BLAKE2b-256 |
f062867d26758752ef43de6c0f369eb2965e5cc46a632d831931027a1170632e
|
Provenance
The following attestation bundles were made for localpython-0.2.0.tar.gz:
Publisher:
publish.yml on yaliach/local-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localpython-0.2.0.tar.gz -
Subject digest:
69c005a9e57a1c40a40d633c5dd5e8f84dcf22fd8a615fce442886db4ca1bebe - Sigstore transparency entry: 380438757
- Sigstore integration time:
-
Permalink:
yaliach/local-python@2901a24a3259e443530295bc6f8be82971498eb3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yaliach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2901a24a3259e443530295bc6f8be82971498eb3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file localpython-0.2.0-py3-none-any.whl.
File metadata
- Download URL: localpython-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9673cbe283b50b4363ee2fb2321252ed23f3fadfd01e2ceac7d4b5b04ca0d97
|
|
| MD5 |
4e817c1e35236cfc6b22f9cd3089f45b
|
|
| BLAKE2b-256 |
63929c9e9e8286c79e8e77525be1a6d90537ce9241c148ea9766a17e7d6b9338
|
Provenance
The following attestation bundles were made for localpython-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on yaliach/local-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localpython-0.2.0-py3-none-any.whl -
Subject digest:
b9673cbe283b50b4363ee2fb2321252ed23f3fadfd01e2ceac7d4b5b04ca0d97 - Sigstore transparency entry: 380438761
- Sigstore integration time:
-
Permalink:
yaliach/local-python@2901a24a3259e443530295bc6f8be82971498eb3 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yaliach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2901a24a3259e443530295bc6f8be82971498eb3 -
Trigger Event:
push
-
Statement type: