Python Forum
sys.executable python 2.7 vs 3.6
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sys.executable python 2.7 vs 3.6
#1
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)
Reply
#2
Import the modules and use the help() function to see the docs.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
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
Reply
#4
Does that script normally run under both versions?
Reply
#5
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.
Reply
#6
Try running from command line.
Reply
#7
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,319 May-24-2022, 07:02 AM
Last Post: netanelst
  Python executable Script (Wrapper) Hwang 2 1,880 Jan-12-2022, 06:53 PM
Last Post: Hwang
  No module named '_cffi_backend' error with executable not with python script stephanh 2 5,658 Nov-25-2021, 06:52 AM
Last Post: stephanh
  Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable kmarien 3 3,657 Nov-30-2020, 04:10 PM
Last Post: buran
  Make a Python program executable in Windows Pedroski55 1 2,107 Sep-26-2020, 12:34 AM
Last Post: bowlofred
  How to keep a loop containing a web import working in python executable? coder1384 3 2,863 Feb-22-2020, 06:49 PM
Last Post: snippsat
  Error while trying to see Python version with "sys.executable" karkas 5 5,987 Feb-09-2020, 01:55 AM
Last Post: karkas
  Best method: Python script called from another app, package as complete executable ironfelix717 2 2,124 Jul-24-2019, 07:39 AM
Last Post: DeaD_EyE
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,620 May-11-2019, 08:12 PM
Last Post: keames

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020