Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
on a system w/o python3
#5
to start with, i need to change all the hash-bang references back to just plain python (from python3). for those scripts that work better on python3 i add code (running on python2) that checks for the existence of python3, and if it does exit, switch over to python3, which most likely will mean something like:
if sys.version_info.major<3:
    for p in os.environ.get('PATH','').split(':'):
        if p and os.path.exists(p+'/python3'):
            os.execvp('python3',['python3']+sys.argv)
or maybe
if sys.version_info.major<3:
    for p in os.environ.get('PATH','').split(':'):
        if p and os.path.exists(p+'/python3'):
            os.execvp(p+'/python3',['python3']+sys.argv)
where the difference is the 1st argument in the call to os.execvp

anyone know of a way, at least in Linux, in python2, to get the full path of the interpreter being used?

so in Windows does Windows support the #! or does Python.  when a script is run in Windows, what decides which interpreter starts first?  if Python is interpreting the #! can it handle other language interpreters if it is the first interpreter to start?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
on a system w/o python3 - by Skaperen - Nov-07-2017, 01:29 AM
RE: on a system w/o python3 - by metulburr - Nov-07-2017, 01:39 AM
RE: on a system w/o python3 - by Skaperen - Nov-07-2017, 02:04 AM
RE: on a system w/o python3 - by sparkz_alot - Nov-07-2017, 02:08 AM
RE: on a system w/o python3 - by Skaperen - Nov-07-2017, 02:23 AM
RE: on a system w/o python3 - by wavic - Nov-07-2017, 10:41 AM
RE: on a system w/o python3 - by Larz60+ - Nov-07-2017, 04:00 PM
RE: on a system w/o python3 - by Skaperen - Nov-08-2017, 01:27 AM
RE: on a system w/o python3 - by snippsat - Nov-07-2017, 04:29 PM
RE: on a system w/o python3 - by metulburr - Nov-07-2017, 09:19 PM
RE: on a system w/o python3 - by metulburr - Nov-08-2017, 02:14 AM
RE: on a system w/o python3 - by snippsat - Nov-08-2017, 02:51 AM
RE: on a system w/o python3 - by Skaperen - Nov-08-2017, 03:30 AM
RE: on a system w/o python3 - by metulburr - Nov-08-2017, 01:42 PM
RE: on a system w/o python3 - by Skaperen - Nov-08-2017, 11:26 PM
RE: on a system w/o python3 - by metulburr - Nov-09-2017, 12:16 AM
RE: on a system w/o python3 - by Skaperen - Nov-10-2017, 07:28 AM
RE: on a system w/o python3 - by wavic - Nov-09-2017, 12:24 AM
RE: on a system w/o python3 - by metulburr - Nov-10-2017, 10:27 AM
RE: on a system w/o python3 - by wavic - Nov-10-2017, 02:34 PM
RE: on a system w/o python3 - by snippsat - Nov-10-2017, 03:32 PM
RE: on a system w/o python3 - by Skaperen - Nov-11-2017, 05:24 AM
RE: on a system w/o python3 - by snippsat - Nov-11-2017, 09:02 AM
RE: on a system w/o python3 - by Skaperen - Nov-12-2017, 04:28 AM

Forum Jump:

User Panel Messages

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