Virtual Environments
PPM automatically manages Python virtual environments to ensure clean, isolated dependency management alongside your JavaScript packages. This page explains how PPM’s virtual environment system works and how to customize it for your needs.Why Virtual Environments Matter
The Problem
Python’s global package installation can lead to:- Dependency conflicts between different projects
- Version incompatibilities when switching between projects
- System pollution with packages not needed globally
- Deployment inconsistencies between development and production
PPM’s Solution
PPM automatically creates and manages virtual environments: ✅ Automatic creation when initializing projects✅ Intelligent activation for all Python operations
✅ Cross-platform compatibility (Windows, macOS, Linux)
✅ Integration with JavaScript workflows
✅ Zero configuration required for most use cases
How It Works
Automatic Environment Creation
When you runppm init
or ppm install
, PPM:
1
Detection
Scans for existing virtual environments:
.venv/
directoryvenv/
directoryenv/
directory- Custom paths specified in configuration
2
Creation
Creates a new virtual environment if none exists:
3
Activation
Automatically activates the environment for Python operations:
4
Installation
Installs Python dependencies within the isolated environment
Environment Lifecycle
PPM manages the complete lifecycle:Configuration Options
Basic Configuration
Configure virtual environments inproject.toml
:
Advanced Configuration
Multiple Environments
Define different environments for different use cases:Environment Management Commands
Creation and Activation
Information and Status
Maintenance
Python Version Management
Version Detection
PPM automatically detects available Python versions:Version Selection Priority
PPM uses this order to select Python versions:- Project configuration (
project.toml
) - Runtime argument (
--python 3.10
) - Environment variable (
PPM_PYTHON_VERSION
) - pyproject.toml (if present)
.python-version
file (pyenv compatibility)- System default Python
Multiple Python Versions
Work with multiple Python versions:Integration Patterns
With JavaScript Tools
PPM seamlessly integrates Python virtual environments with JavaScript tooling:With Docker
Use PPM virtual environments in Docker:With CI/CD
GitHub Actions example:Troubleshooting
Common Issues
Virtual environment not activated
Virtual environment not activated
Problem: Python packages not found or wrong version usedSolution:
Permission errors on Windows
Permission errors on Windows
Problem: Cannot create virtual environment due to permissionsSolution:
Python version not found
Python version not found
Problem: PPM cannot find specified Python versionSolution:
SSL certificate errors
SSL certificate errors
Problem: pip cannot download packages due to SSL errorsSolution:
Debugging Commands
Best Practices
Project Structure
Organize your virtual environments consistently:Environment Naming
Use descriptive names for multiple environments:Dependency Management
Keep virtual environments clean:Team Collaboration
Ensure consistent environments across team:- Commit
project.toml
andppm.lock
- Include
.venv/
in.gitignore
- Document any special setup requirements
- Use exact Python versions in production
- Test with multiple Python versions in CI
PPM’s virtual environment management eliminates the complexity of Python environment setup while maintaining full compatibility with existing Python tooling. The automatic creation and activation ensures your team never has to worry about environment issues again.