Check if Python 3 installed?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9824
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Check if Python 3 installed?
A quick Google search for "checking python 3 version returns python 2" reveals you're not alone.
One of the more promising proposed solutions I came across is using this when checking Python 3: python3 --version
Haven't checked it myself, just passing along what I found.
One of the more promising proposed solutions I came across is using this when checking Python 3: python3 --version
Haven't checked it myself, just passing along what I found.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: Check if Python 3 installed?
Perhaps python3 needs to be added to the $PATH variable on your computer.
Do an internet search for this phase: add a path to the path environment variable
and look for information regarding your computer (Mac, Windows, Linux, etc.).
Hope that helps,
Bob
Do an internet search for this phase: add a path to the path environment variable
and look for information regarding your computer (Mac, Windows, Linux, etc.).
Hope that helps,
Bob
Re: Check if Python 3 installed?
Yes, it's a PATH problem. But the real problem is to know this damned Python 3 path without opening Terminal.
It appears the problem is the same when calling Python from Applescript.
I finally found a solution here:
https://stackoverflow.com/questions/306 ... -to-change
So, in LC, instead of simply writing:
You have to know where Python 3 was installed, like this:
It appears the problem is the same when calling Python from Applescript.
I finally found a solution here:
https://stackoverflow.com/questions/306 ... -to-change
So, in LC, instead of simply writing:
Code: Select all
put shell("python3 --version")
Code: Select all
put shell(". ${HOME}/.bash_profile; python3 -c 'import sys; print(sys.executable)'") into python3_path
delete last char of python3_path // last char is a CR !
// now we have Python 3 path
put shell(python3_path & " --version")
Last edited by Zax on Mon Mar 14, 2022 10:50 am, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
So, here I am in my school, and 3 Mums having phoned me to say that their wee sprogs are ill (nice of them to do that
at the last minute so I drove down here [45 mins] 6 hours earlier than I need to) I am messing around with LC 8.1.10
on Mac OS 10.7.5 . . .
- -
Just installed that . . .
- - -
So; what worked on Mac OS 12.3 does not work on Mac OS 10.7.5
at the last minute so I drove down here [45 mins] 6 hours earlier than I need to) I am messing around with LC 8.1.10
on Mac OS 10.7.5 . . .
- -
Just installed that . . .
- - -
So; what worked on Mac OS 12.3 does not work on Mac OS 10.7.5
Re: Check if Python 3 installed?
It's because Python 2 is pre-installed on MacOS 10.x.richmond62 wrote: ↑Mon Mar 14, 2022 10:07 amSo; what worked on Mac OS 12.3 does not work on Mac OS 10.7.5
When Python 3 is manually installed, LC (or Applescript) are unable to know where Python 3 is installed.
stackoverflow wrote:The Python 2.6.5 installer modifies your ~/.bash_profile file to put Python 2.6.5's bin directory at the start of your $PATH, ahead of /usr/bin which is where the OS's default Python interpreter lies. That profile is automatically read when you log in via Terminal, but not when using do shell script. You either need to specify the full path to the python executable you want (probably the best option), or you could have your script read the bash profile beforehand (though be aware that do shell script uses sh, not bash):
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
Tedious nonsense:
- - -
Cripes: time to become an alcoholic big-time.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
Pass me the Vodka right now.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
Code: Select all
delete last of python3_path
Code: Select all
delete last char of python3_path
- -
sacre cochon!
https://www.macrumors.com/2022/01/28/ap ... acos-12-3/
Re: Check if Python 3 installed?
Right! I updated my post.
As Python 3 is now pre-installed on MacOS 12.x, LC or Applescript will not encounter problems to found Python 3.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
Last edited by richmond62 on Mon Mar 14, 2022 1:14 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
Does not help that much as a very large number of one's potential targets may be running earlier recensions of MacOS than 12.3.As Python 3 is now pre-installed on MacOS 12.x, LC or Applescript will not encounter problems to found Python 3.
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Check if Python 3 installed?
I wonder if one could check for the presence of the Install Certificates.command
document (normally stored inside a folder called 'Python' & a number in the Applications folder?
- -
Pseudocode:
-
-
That works!
document (normally stored inside a folder called 'Python' & a number in the Applications folder?
- -
Pseudocode:
Code: Select all
if there is a file <path to file> then
break out the vodka
end if
That works!