py or pymanager commands for better multi-version management. Why? Provides automatic installation, unified version management, better conflict resolution, and seamless updates without manual PATH configuration.
📥 Download Python
Official Download: Python Downloads | Latest stable versions: 3.13.x, 3.12.x, 3.11.x
Installation Types: Use MSIX for better security (Windows 10/11) or MSI for legacy systems (Windows 7/8). MSIX auto-updates and runs in sandbox mode.
Documentation: Official Windows Setup Guide
🔍 Check Installed Python Versions
View all Python installations on your system with their paths:
py --list # Shows installed versions
pymanager list # Alternative manager
py --list-path # Shows installation paths
py -0p # Get default Python path
Example Output: -V:3.13 * -V:3.12 -V:3.11
⚙️ Install Specific Python Version
Use pymanager to install multiple Python versions side-by-side:
pymanager install 3.12.8
pymanager list # Verify installation
🔄 Switch Python Versions
Temporary Change (Current Session Only):
set PY_PYTHON=3.13 # CMD
$env:PY_PYTHON="3.13" # PowerShell
Permanent Change (System-wide):
setx PY_PYTHON "3.13" # Sets environment variable permanently
Run Script with Specific Version:
py -3.12 myfile.py # Run script with Python 3.12
py -3.13 -m venv myenv # Create venv with Python 3.13
py -3.11 -c "import sys; print(sys.version)" # Quick version check
📦 Pip Package Management
Best Practice: Always use virtual environments to avoid dependency conflicts. For global installation:
py -3.10 -m pip install paramiko # Install specific package
py -3.10 -m pip install requests flask # Multiple packages
Install from requirements.txt:
py -3.10 -m pip install -r requirements.txt
Upgrade Pip to Latest Version:
py -3.10 -m pip install --upgrade pip
List All Installed Packages:
py -3.13 -m pip list # All packages
py -3.13 -m pip list --outdated # Outdated packages only
py -3.13 -m pip show requests # Details of specific package
🌳 View Package Dependencies (DevOps Essential)
Visualize package dependency tree to understand relationships and troubleshoot conflicts:
py -3.10 -m pip install pipdeptree # Install tool
py -3.10 -m pipdeptree # Show all dependencies
py -3.10 -m pipdeptree -p requests # Dependencies of specific package
py -3.10 -m pipdeptree --reverse # Show reverse dependencies
💡 Virtual Environment Management
Create isolated Python environments for each project:
# Create virtual environment
py -3.12 -m venv myproject_env
# Activate environment
myproject_env\Scripts\activate # CMD
myproject_env\Scripts\Activate.ps1 # PowerShell
# Install packages in venv
pip install django pandas numpy
# Deactivate when done
deactivate
🚀 Pro Tips
- Add Python to PATH: Check "Add Python to PATH" during installation for easy access
- py launcher: Use
pyinstead ofpythonfor better version management on Windows - Keep Updated: Regularly update pip with
py -m pip install --upgrade pip - Requirements: Generate requirements.txt with
pip freeze > requirements.txt - Cache Clear: Clear pip cache if installation fails:
py -m pip cache purge
Related: Python Virtual Environments | PyPI Package Registry | pip Commands Cheat Sheet