Pyvenv puts both Python 2 and Python 3 in the same environment. Shocked!

Malik Rumi malik.a.rumi at
Tue Dec 20 21:37:35 EST 2016

I just created a new venv using pyvenv from a 2.7 install. Now I am shocked to see that I can get both 2.7 and 3.4 in this same venv:

(memory) malikarumi at Tetuoan2:~/Projects/cannon/New2.7Projects/memory$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(memory) malikarumi at Tetuoan2:~/Projects/cannon/New2.7Projects/memory$ python3
Python 3.4.2 (default, Apr 17 2015, 18:47:05) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.

I did not even know this was possible. Doesn’t that defeat the purpose? More to the point, how do I make sure I am using the right one? If I want the interpreter, that’s easy. But what happens when I want to install and use a program like Django? How do I control which interpreter Django uses? I’ve been through the official docs a couple of times today, but detailed explanations of pyvenv, let alone this dual version feature, have not been found. If you can point me to a good one, please do. Meanwhile...

I hoped maybe using different versions of pip would solve the problem, but pip2 list and pip3 list are identical – hence, the very problem I thought venv’s were supposed to avoid. 


More information about the Python-list mailing list