Python Forum
sys.executable python 2.7 vs 3.6 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: sys.executable python 2.7 vs 3.6 (/thread-1442.html)



sys.executable python 2.7 vs 3.6 - mcmxl22 - Jan-03-2017

This works fine in Python 2.7.13 but only returns an empty >>> prompt in python 3.6. What changed?
import subprocess
import sys

web = [sys.executable, 'web.py']
subprocess.call(web)



RE: sys.executable python 2.7 vs 3.6 - wavic - Jan-03-2017

Import the modules and use the help() function to see the docs.


RE: sys.executable python 2.7 vs 3.6 - snippsat - Jan-03-2017

it has not changed,guess there is path problem.
When you run that script it fill in sys.executable(path) and try to run wep.py(has no path).
So if web.py is not in same folder as script you run there will be problems Confused


RE: sys.executable python 2.7 vs 3.6 - nilamo - Jan-04-2017

Does that script normally run under both versions?


RE: sys.executable python 2.7 vs 3.6 - mcmxl22 - Jan-04-2017

This web.py script runs fine in both 2.7 and 3.6.
import webbrowser

def websites():
    new = 2
    choice = input('Type site name:\n> ') # I have raw_input here to run in 2.7
    site = choice
    url1 = 'www..com'
    url = 'http://' + url1[:4] + site + url1[4:]
    webbrowser.open(url,new)

if __name__ == "__main__":
    websites()
I do have both programs in the same directory so I don't know why the one won't open the other in 3.6.


RE: sys.executable python 2.7 vs 3.6 - snippsat - Jan-04-2017

Try running from command line.


RE: sys.executable python 2.7 vs 3.6 - mcmxl22 - Jan-04-2017

It runs fine from the command line. I hadn't setup my command line to run both versions of python so I had to go figure that out. Now it works.