I have both Python 2.7 and 3.3 installed in my box. How would I change python-green
configuration to use one or the other without changing /usr/bin/python symbolic link?
How to change python version used by python-green
124 views Asked by douglaslps At
3
There are 3 answers
0
On
Using venv
as Sharadh suggests is absolutely the best way to go about this.
Having said that, it can be useful to know that green actually installs three application binaries:
green
greenX
greenX.Y
Where X
is the major version of python (2 or 3) and Y is the minor version of python. So lets say you install green under the "system" installation of Python 3.3 and then 3.4. The following would occur:
green <- Points to green in 3.3
green3 <- Points to green in 3.3
green3.3 <- Points to green in 3.3
green <- Overwrites the previous green, now points to 3.4
green3 <- Overwrites the previous green3, now points to 3.4
green3.4 <- Points to green in 3.4
So, in summary:
- Use
venv
-- it's much more sane. - If you must use multiple "system" python versions, use
greenX.Y
in all your commands, and you'll always get the correct one.
Try
venv
. This creates a virtual environment where all scripts use a particular python version by default.Once you activate
venv
,To stop using this environment,
Most packages, even the ones which support multiple Python versions, don't have run-time switches. So, you need to install green after you activate venv. Otherwise, the currently active (in your case, global) python version - lets assume 2.7 - calls its globally installed
pip
, which would install green for Python 2.7.