hi , I have two different versions of python on my ubuntu machine : 2.7 and 3.4 . my question is how to tell sys.executable to use python 3.4 ?
this is what I get when I run the code :
`>>> import sys

print sys.executable

which is python 2.7 but I want to use python 3.4


Edited by fonzali

3 Years
Discussion Span
Last Post by fonzali

It goes the other way round. If you're already running python 2, sys.executable is the path to the python 2.7 executable. If you're already running python 3, sys.executable is the path to the python 3.4 executable. If you want to run a script with python 3.4, use the command

python3 myscript.py

in a terminal, or use a shebang line

#!/usr/bin/env python3

at the top of your file and simply call ./myscript.py (without the command python).


thanks Gribouillis , I did not think it through before I posted the question . it makes sense now

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.