ESP32: problem with compilation on MacOS 12.3 Monterey

Hi there, since Apple upgraded MacOS Monterey to 12.3 Arduino is not able to find python - apparently there is no more python 2.7 in MacOS. But installing python 3 and making sure it is in $PATH does not help much - still the problem is: Arduino - or as I was told on Arduino Gighub page - ESP32 part of it, is looking for python and not finding it.
Workaround is to run Arduino directly from terminal rather than GUI - then, there is no problem. But that seems dirty trick and probably could be avoided if ESP32 board manager would behave better. Do you know any solution for that please?
This problem is for both: Arduino 1.8.19/20 and 2.x

Problem starts here:

Merged 25 ELF sections
python /Users/me/Library/Arduino15/packages/esp32/hardware/esp32/2.0.2/tools/gen_esp32part.py -q /var/folders/l2/q1yr15k169z43pw_hczk1ckw0000gn/T/arduino_build_890727/partitions.csv /var/folders/l2/q1yr15k169z43pw_hczk1ckw0000gn/T/arduino_build_890727/82-esp32s-test.ino.partitions.bin
...
exec: "python": executable file not found in $PATH
Error compiling for board ESP32 Dev Module.

Of course .zprofile has the path to python.:

papio@MBP16M1papio ~ % echo $PATH

/opt/homebrew/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components

papio@MBP16M1papio ~ % which python

/opt/homebrew/bin/python

papio@MBP16M1papio ~ %

when using such command in terminal all is ok:
papio@MBP16M1papio ~ % open /Applications/Arduino.app

Any suggestion please?
thank you

Yes, I am having the same problem with Monterey 12.3. I have python 3.8 installed with homebrew. I think the problem is that the links now point to python3. On my system, this is what I see.

ershler@Philips-MacBook-Pro ~ % which python
python not found

ershler@Philips-MacBook-Pro ~ % which python3
/opt/homebrew/opt/python@3.8/bin/python3

ershler@Philips-MacBook-Pro ~ % python3
Python 3.8.12 (default, Oct 22 2021, 17:47:41)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

So it's not clear to me how to tell Arduino to use python3.

but I linked python to python3 - it does not help
but when started from terminal it works

btw for whatever reason Arduino 2.x WORKS when started from GUI (after creating the link)
but Arduino 1.8.x does NOT work from GUI

Hi, got exactly the same problem, unable to re-compile sketches that worked previously... I started Arduino.app from terminal and no more success. How did you start ? Just papio@MBP16M1papio ~ % open /Applications/Arduino.app. ? I put my Arduino.app on desktop not in Application folder..

Thanks

open terminal and type:
open /Applications/Arduino.app

1 Like

Yes, but as my Arduino.app remains in /Users/bernardulrich/Downloads.

I start it from there. and I can't find python in my system.
Thus even starting Arduino from Terminal doesn't solve problem.
Any additional advice ? Many Thanks

have the same problem :sob:

enter command:

which python

if it says nothing (as it should since 12.3 MacOS) then enter command:
which python3
this one should return the path - if not, first you must install python3
if it returns the path, link them by using command:
sudo ln -s /path/displayed/above /usr/local/bin/python
provided /usr/local/bin is in your PATH - check by entering command:
echo $PATH
I installed python3 by using brew - you can also install xcode (from appstore)

1 Like

Same problem here. Tried what you suggested (I installed python3), but doesn't seem to work.

say what this command shows (in terminal):
which python

doesn't show anything for me

which python3 shows:

/Library/Frameworks/Python.framework/Versions/3.10/bin/python3

now make this:
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 /usr/local/bin/python
after this command try again with
which python

This is the status on my MacOS Monterey 13.2. (M1)
~ % which python
/usr/local/bin/python

~ % which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3

~ % echo $PATH
/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Compilation of existing code that successfully compiled in 2021,
1.) when starting with GUI gives an error (lack of python)
2.) and when starting with terminal it gives same error but asks for Command Line Developer Tools install (I tried it several times long minutes... , and being asked again and again after end of compilation, and error).....

unfortunately nothing happens

so I propose to install brew and once brew is installed, enter command:
brew install python

brew is here:

and to install brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

1 Like

I performed Homebrew install, and installed Python 3.9.10... (previous trials were done with 3.10 that seems to be fixed in $PATH).
But always remaining compile error python: error: Failed to locate 'python'.

My setup is
~ % which python
/usr/local/bin/python

~ % which python3
/opt/homebrew/bin/python3

and....echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

close Arduino completely (Command Q), even reboot macos
don't start Arduino from GUI
open terminal
type:
open /Applications/Arduino.app
it will start Arduino
it works for me

I would install the latest Python 2 AND Python 3 from here.

% which python
/usr/bin/python

% python -V
Python 2.7.18

% which python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3

% python3 -V
Python 3.9.2

1 Like

true, but the thing is not WRONG python (3 instead of 2) but LACK of python - not visible by the environment variables
and I opened the ticket with Arduino - they told me: "Arduino does NOT use python but the manager for ESP uses" so ticket was closed today

actually I made a link to/opt/homebrew/bin/python not /usr/local/bin/python but since both paths are in $PATH it should not make a difference

papio@MBP16M1papio ~ % ls -la /opt/homebrew/bin/python* | grep -v config
lrwxr-xr-x  1 root   admin  25 15 Mar 15:06 /opt/homebrew/bin/python -> /opt/homebrew/bin/python3
lrwxr-xr-x  1 papio  admin  39 15 Mar 11:17 /opt/homebrew/bin/python3 -> ../Cellar/python@3.9/3.9.10/bin/python3
lrwxr-xr-x  1 papio  admin  41 15 Mar 11:17 /opt/homebrew/bin/python3.9 -> ../Cellar/python@3.9/3.9.10/bin/python3.9