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
/usr/bin/python

which is python 2.7 but I want to use python 3.4

`

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.