Skip to main content

Virtualenv for another version of Python




To exit from a virtual environment, we write in the console

deactivate


Now we can create a virtual environment for python 2.7 that I have on my pc and that is not the default version that appears when I open the prompt line command or when I use Sublime Text...

I just have to write this:
cd..
cd..

to go in my env directory (where I choose to put all my environments)
and write:


and the new environment will be placed in the env2 folder (I can choose whatever name I want). My python 2.7 is in the folder python27, but your could be in another version... do your adjustments.

Now write

cd env2
cd scripts
activate


As you can see ... the (env2) shows that we are under the env2 environment.
If we write the command python, you will see this:
As you can see, the version of python is 2.7, even if in my computer the default version is 3.4.
If write
print "Hello"
it will not show errors, because in this version it is allowed to avoid the parentesis. If we make it in python 3, it will say there's a syntax error.

To exit from this environment, we write:
deactivate.

Comments