Use different Python version to setup Python virtual environment

Learn how to use different Python version to setup Python virtual environment

Steps to use different Python version to setup Python virtual environment

Docs

# Linux
pip install virtualenv
virtualenv venv --python=/usr/local/bin/python
virtualenv venv --python=/usr/local/bin/python3
 
# Windows
##  Method 1 - I don't recommend to use virtualenv as it will have some missing files
pip install virtualenv
virtualenv venv -p `which python`
virtualenv venv -p `which python3`
virtual venv -p "C:\Users\karchunt\AppData\Local\Programs\Python\Python312\python.exe"
 
##  Method 2
"C:\Users\karchunt\AppData\Local\Programs\Python\Python312\python.exe" -m venv venv

Written by

KarChunT

At

Fri Mar 28 2025