Fix Python – Use different Python version with virtualenv

Question

Asked By – Ulf

How do I create a virtual environment for a specified version of Python?

Now we will see solution for issue: Use different Python version with virtualenv


Answer

NOTE: For Python 3.3+, see The Aelfinn’s answer below.


Use the --python (or short -p) option when creating a virtualenv instance to specify the Python executable you want to use, e.g.:

virtualenv --python="/usr/bin/python2.6" "/path/to/new/virtualenv/"

This question is answered By – Daniel Roseman

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0