Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if python3 only
#1
i have a script that is version agnostic. it runs correctly under python2 and python3. but i want to make it be an executable #! script that will run under a system that has python2 only (named python there) and will run under a system that has python3 only after the script is downloaded (from the same online copy) and made executable, at least on Linux if not also Windows and BSD.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
What you need is a script which scans the system to determine which version of python it has, then launches a process by invoking the correct version of the interpreter.

I don't think it is a good idea to write version agnostic code: write python 3 code and install python 3 on system that don't have it.
Reply
#3
i don't always have the option to install Python3 on these systems even if its sysadmin does. i'm trying make code that just works by downloading a file, not installing a "package".

i would like to see Python3 totally take over. waiting for Python2 EOL. soon!
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
(Apr-20-2018, 12:18 AM)Skaperen Wrote: i don't always have the option to install Python3 on these systems even if its sysadmin does. i'm trying make code that just works by downloading a file, not installing a "package".
Then freeze code is an option,pyinstaller is what i think dos the best job.
I have a tutorial Sound-player standalone,
so use virtual environment first eg pipenv to have control over dependencies.
Have to think all that's needed to be stand alone,
it's annoying when try to run and get message eg missing libavbin.so.10(Linux) in my example.
Reply
#5
i'm talking about simple scripts with no dependencies, otherwise i would be doing package installs.

and besides, that python environment thing never worked. i think i had a different expectation of it than its creators intended. i was looking for something to let me avoid doing an install of some other version of Python (outside of the environment). a VM would still be the way to do it.
Tradition is peer pressure from dead people

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


Forum Jump:

User Panel Messages

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