Multiple Python versions on Windows: use py, venv and absolute paths
Keep Python 3.11 and 3.12 side by side, create a venv per app, and pin the interpreter instead of relying on PATH or the Store alias.
- Build
- 26100.33650
- Edition
- Standard / Datacenter
- Architecture
- x64
- Support
- Documentation (E1)
- Evidence
- E1Official documentation
- Verified
- 2026-10-29
- Page type
- Method
The short answer
Section titled “The short answer”Use the py launcher to select a version and a venv per app to pin dependencies:
py -0ppy -3.11 -m venv C:\apps\api-a\.venvC:\apps\api-a\.venv\Scripts\python.exe -m pip install -r requirements.txtThe venv’s python.exe is the production selector. Do not rely on python from PATH, and do not install app dependencies globally.
See what is installed
Section titled “See what is installed”py -0ppy -3.11 --versionpy -3.12 --versionwhere.exe pythonIf python opens the Microsoft Store, disable the App Execution Alias or use py/absolute paths. The Store alias is a common source of “wrong Python” confusion.
Per-app venv
Section titled “Per-app venv”py -3.11 -m venv C:\apps\api-a\.venvC:\apps\api-a\.venv\Scripts\python.exe -m pip install --upgrade pipC:\apps\api-a\.venv\Scripts\python.exe -m pip install -r C:\apps\api-a\requirements.txtThe venv records its base interpreter. Recreating it is cheaper than debugging a mixed global site-packages tree.
For a service, use the absolute venv python:
C:\apps\api-a\.venv\Scripts\python.exe -m waitress --listen=127.0.0.1:8000 app:appVerify
Section titled “Verify”C:\apps\api-a\.venv\Scripts\python.exe -c "import sys; print(sys.executable); print(sys.version)"C:\apps\api-a\.venv\Scripts\python.exe -m pip listCheck sys.executable points at the app venv, not C:\Python311\python.exe.
Upgrade path
Section titled “Upgrade path”- Install the new Python beside the old.
- Create a new venv for the app (
py -3.12 -m venv .venv312). - Install from the lock/requirements; run tests.
- Switch the service path to the new venv.
- Keep the old venv until rollback is no longer needed.
Lab boundary
Section titled “Lab boundary”E1. The lab did not install multiple Python versions or run a WSGI service; the commands are the selector pattern to verify on Server 2025.