Python Language Virtual environments Creating a virtual environment for a different version of python

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


Assuming python and python3 are both installed, it is possible to create a virtual environment for Python 3 even if python3 is not the default Python:

virtualenv -p python3 foo


virtualenv --python=python3 foo   


python3 -m venv foo


pyvenv foo

Actually you can create virtual environment based on any version of working python of your system. You can check different working python under your /usr/bin/ or /usr/local/bin/ (In Linux) OR in /Library/Frameworks/Python.framework/Versions/X.X/bin/ (OSX), then figure out the name and use that in the --python or -p flag while creating virtual environment.

Got any Python Language Question?