Check if Python 3 installed?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9824
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Check if Python 3 installed?

Post by FourthWorld » Sun Mar 13, 2022 4:52 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bobcole
VIP Livecode Opensource Backer
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?

Post by bobcole » Sun Mar 13, 2022 5:12 pm

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

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Check if Python 3 installed?

Post by Zax » Mon Mar 14, 2022 9:21 am

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:

Code: Select all

put shell("python3 --version")
You have to know where Python 3 was installed, like this:

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 10:07 am

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 . . .
-
Screen Shot 2022-03-14 at 11.01.35 AM.png
-
Just installed that . . .
-
Screen Shot 2022-03-14 at 10.53.14 AM.png
-
Screen Shot 2022-03-14 at 10.54.52 AM.png
-
So; what worked on Mac OS 12.3 does not work on Mac OS 10.7.5

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Check if Python 3 installed?

Post by Zax » Mon Mar 14, 2022 10:17 am

richmond62 wrote:
Mon Mar 14, 2022 10:07 am
So; what worked on Mac OS 12.3 does not work on Mac OS 10.7.5
It's because Python 2 is pre-installed on MacOS 10.x.
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):

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 10:18 am

Screen Shot 2022-03-14 at 11.11.09 AM.png
-
Tedious nonsense:
-
Screen Shot 2022-03-14 at 11.16.06 AM.png
-
Screen Shot 2022-03-14 at 11.17.24 AM.png
-
Cripes: time to become an alcoholic big-time.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 10:19 am

Screen Shot 2022-03-14 at 11.18.50 AM.png
-
Pass me the Vodka right now.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 10:25 am

Code: Select all

delete last of python3_path
looks a bit odd: possiblement:

Code: Select all

delete last char of python3_path
Нали?
-
Screen Shot 2022-03-14 at 11.24.58 AM.png
-
sacre cochon!

https://www.macrumors.com/2022/01/28/ap ... acos-12-3/

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Check if Python 3 installed?

Post by Zax » Mon Mar 14, 2022 10:54 am

richmond62 wrote:
Mon Mar 14, 2022 10:25 am

Code: Select all

delete last char of python3_path
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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 1:11 pm

Last edited by richmond62 on Mon Mar 14, 2022 1:14 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 1:13 pm

As Python 3 is now pre-installed on MacOS 12.x, LC or Applescript will not encounter problems to found Python 3.
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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Check if Python 3 installed?

Post by richmond62 » Mon Mar 14, 2022 1:22 pm

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?
-
Screen Shot 2022-03-14 at 2.22.38 PM.png
-
Pseudocode:

Code: Select all

if there is a file <path to file> then
break out the vodka
end if
-
Screen Shot 2022-03-14 at 2.28.11 PM.png
-
That works!

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”