npx-like tool for Python: switch versions and manage virtual environments
Project description
Pyxenv 🐍 - Python Version/Environment Manager
npx for Python - Manage Python versions and virtual environments with ease
Pyxenv is a command-line tool inspired by Node.js's npx, designed to simplify managing multiple Python versions and virtual environments.
Features
- Quick version switching - Run scripts with different Python versions
- Automatic installation - Downloads and installs Python versions automatically (Windows)
- Virtual environment management - Create and activate virtual environments easily
- Smart detection - Lists all available Python versions
- Cross-platform - Support for Windows, Linux and macOS
- Zero configuration - Works immediately after installation
Installation
Via pip (recommended)
pip install pyxenv
Via GitHub
git clone https://github.com/luigicfilho/pyxenv.git
cd pyxenv
pip install -e .
Quick Usage
Run script with specific version
# Run script.py with Python 3.11
pyxenv 3.11 script.py
# With arguments
pyxenv 3.11 script.py --arg1 value1 --arg2 value2
Manage Python versions
# List versions installed by pyxenv
pyxenv --list
# List all versions (including globals)
pyxenv --list-all
# Auto-install (Windows)
pyxenv 3.12 script.py # Installs 3.12 if not exists
Manage virtual environments
# Create virtual environment
pyxenv 3.11 --create-env my-project
# Create with default name (pyxenv-3.11)
pyxenv 3.11 --create-env
# Activate environment
pyxenv --activate my-project
# List environments
pyxenv --list-envs
Examples
Multi-version development
# Test your code in different versions
pyxenv 3.8 test_script.py
pyxenv 3.9 test_script.py
pyxenv 3.11 test_script.py
pyxenv 3.12 test_script.py
Isolated projects
# Django project with Python 3.11
pyxenv 3.11 --create-env django-project
pyxenv --activate django-project
pip install django
django-admin startproject mysite
# FastAPI project with Python 3.12
pyxenv 3.12 --create-env fastapi-project
pyxenv --activate fastapi-project
pip install fastapi uvicorn
CI/CD
# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Install pyxenv
run: pip install pyxenv
- name: Run tests
run: pyxenv ${{ matrix.python-version }} -m pytest
Commands
| Command | Description |
|---|---|
pyxenv <version> <script> |
Run script with specific version |
pyxenv --list |
List versions installed by pyxenv |
pyxenv --list-all |
List all detected versions |
pyxenv --create-env <name> |
Create virtual environment |
pyxenv --activate <name> |
Activate virtual environment |
pyxenv --list-envs |
List created environments |
pyxenv --version |
Show pyxenv version |
Directory Structure
~/.pyxenv/
├── pythons/ # Installed Python versions
│ ├── 3.8.10/
│ ├── 3.11.5/
│ └── 3.12.0/
└── envs/ # Virtual environments
├── my-project/
├── django-app/
└── pyxenv-3.11/
Configuration
pyxenv works without configuration, but you can customize:
# ~/.pyxenv/config.py (optional)
pyxenv_HOME = Path.home() / ".pyxenv"
PYTHON_DIR = pyxenv_HOME / "pythons"
ENV_DIR = pyxenv_HOME / "envs"
Troubleshooting
Python not found
# Check available versions
pyxenv --list-all
# Install specific version (Windows)
pyxenv 3.11 --version # Auto-installs
Virtual environment not activating
# Check if it exists
pyxenv --list-envs
# Recreate if necessary
pyxenv 3.11 --create-env env-name
Contributing
Contributions are welcome! See CONTRIBUTING.md for details.
Development setup
# Clone repository
git clone https://github.com/luigicfilho/pyxenv.git
cd pyxenv
# Install development dependencies
pip install -e .
# Run tests
pytest
# Check coverage
pytest --cov=pyxenv --cov-report=html
Run tests
# All tests
pytest
# Specific tests
pytest tests/test_cli.py
# With verbose output
pytest -vv
# With coverage
pytest --cov=pyxenv --cov-report=term-missing
Code style
# Format code
black pyxenv tests
# Sort imports
isort pyxenv tests
# Check style
flake8 pyxenv tests
# Type checking
mypy pyxenv
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Luigi C. Filho
- Email: lcdev@lcdesenvolvimentos.com.br
- GitHub: @luigicfilho
Acknowledgments
- Inspired by Node.js's npx
- Python community for excellent documentation
Project Status
- Python version detection
- Virtual environment management
- Automatic installation (Windows)
- Automatic installation (Linux/macOS) - In development
- Download cache - Planned
- Auto-update - Planned
Useful Links
Roadmap
v0.2.0
- pyenv support
- Auto-install on Linux/macOS
- Installer cache
v0.3.0
- Interactive TUI interface
- Project configuration (.pyxenvrc)
- Docker integration
v1.0.0
- Stable API
- Complete documentation
- Verified PyPI package
Inspiration and Alternatives
- pyenv - Complete Python version manager
- virtualenv - Virtual environment creation
- pipx - Install and run Python applications
- conda - Package and environment manager
pyxenv combines the best of these worlds with the simplicity of npx!
Star History
If this project has been useful to you, consider giving it a ⭐!
Made with ❤️ by Luigi C. Filho
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 pyxenv-0.2.0.tar.gz.
File metadata
- Download URL: pyxenv-0.2.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2f4df365763db525df91f805551eb57089d7b13293b2c91778aefaaed810779
|
|
| MD5 |
c5adfbf2bc27ea336b906d34a676672d
|
|
| BLAKE2b-256 |
27fb852a596ef73e97e79c67c86c7565c631f7e35634db388102c3c7d3e7f5d1
|
Provenance
The following attestation bundles were made for pyxenv-0.2.0.tar.gz:
Publisher:
release-pypi.yml on luigi-sw/LCSoft.Pyxenv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyxenv-0.2.0.tar.gz -
Subject digest:
a2f4df365763db525df91f805551eb57089d7b13293b2c91778aefaaed810779 - Sigstore transparency entry: 660711499
- Sigstore integration time:
-
Permalink:
luigi-sw/LCSoft.Pyxenv@683ada6930570f19d5cb38505d6a0bd4f26d1aef -
Branch / Tag:
refs/heads/main - Owner: https://github.com/luigi-sw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@683ada6930570f19d5cb38505d6a0bd4f26d1aef -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyxenv-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyxenv-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a96c9fb684573c0f90d291c570519561b90f34be13fbd05abf43129ab3f22df
|
|
| MD5 |
98ee54b56aa4c8d4a4700f3ece121c0f
|
|
| BLAKE2b-256 |
01ae21c40505c3d3c2dbcb45759f4167c918359bfcbd18788b634f8a08ea586f
|
Provenance
The following attestation bundles were made for pyxenv-0.2.0-py3-none-any.whl:
Publisher:
release-pypi.yml on luigi-sw/LCSoft.Pyxenv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyxenv-0.2.0-py3-none-any.whl -
Subject digest:
4a96c9fb684573c0f90d291c570519561b90f34be13fbd05abf43129ab3f22df - Sigstore transparency entry: 660711502
- Sigstore integration time:
-
Permalink:
luigi-sw/LCSoft.Pyxenv@683ada6930570f19d5cb38505d6a0bd4f26d1aef -
Branch / Tag:
refs/heads/main - Owner: https://github.com/luigi-sw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@683ada6930570f19d5cb38505d6a0bd4f26d1aef -
Trigger Event:
workflow_dispatch
-
Statement type: