Python Forum

Full Version: sys.executable python 2.7 vs 3.6
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
Import the modules and use the help() function to see the docs.
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
Does that script normally run under both versions?
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.
Try running from command line.
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.