Page 2 of 2
Re: Check if Python 3 installed?
Posted: Sun Mar 13, 2022 4:52 pm
by FourthWorld
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.
Re: Check if Python 3 installed?
Posted: Sun Mar 13, 2022 5:12 pm
by bobcole
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
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 9:21 am
by Zax
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:
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")
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:07 am
by richmond62
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
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:17 am
by Zax
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):
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:18 am
by richmond62
-
Tedious nonsense:
-
-
-
Cripes: time to become an alcoholic big-time.
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:19 am
by richmond62
-
Pass me the Vodka right now.
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:25 am
by richmond62
looks a bit odd: possiblement:
Нали?
-
-
sacre cochon!
https://www.macrumors.com/2022/01/28/ap ... acos-12-3/
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 10:54 am
by Zax
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.
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 1:11 pm
by richmond62
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 1:13 pm
by richmond62
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.
Re: Check if Python 3 installed?
Posted: Mon Mar 14, 2022 1:22 pm
by richmond62
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:
Code: Select all
if there is a file <path to file> then
break out the vodka
end if
-
-
That works!