Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Virtualenv , python 3?

Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks.

OK I realized virtualenv is not what I'm looking for.

like image 485
mk12 Avatar asked Sep 12 '09 20:09

mk12


2 Answers

It's an old question by now, but I found it myself on top of google search for the answer, and I don't think the answers provided are what people are looking for.

As I understand it you want to create different virtual environments with different Python versions?

This is very easy, and you only need virtualenv itself.

For, say, a Python 3:

$ virtualenv -p python3 p34env

(...)
New python executable in p34env/bin/python3.4
Also creating executable in p34env/bin/python
Installing setuptools, pip...done.

$ source p34env/bin/activate

(p34env)$ python -V
Python 3.4.2

(p34env)$ deactivate 
$

You use the source command to activate the venv, and deactivate to - you guessed it - deactivate it. Notice the prompt changes to indicate the env.

For your system's standard version of Python you just skip the -p python3 argument, and you can use the argument to point to any version you want given a path.

The last argument is the name (p34env) and you can make as many as you like, just give them different names.

like image 188
henrikstroem Avatar answered Nov 15 '22 19:11

henrikstroem


Your use case doesn't actually need virtualenv. You just need to install several different Python versions.

like image 24
Lennart Regebro Avatar answered Nov 15 '22 21:11

Lennart Regebro