exec: "python": executable file not found in $PATH on Arduino IDE
Asked Answered
S

5

11

So I'm trying to run this really simple code on my LCD display, using an ESP32. When I compile the code in the Arduino IDE I get no errors. But, when I try to upload it, I get the following error:

exec: "python": executable file not found in $PATH
Error compiling for board DOIT ESP32 DEVKIT V1.

I'm running the Mac OS Monterey, on an M1 MacBook Air.

I did find some information here, but it wasn't what I was looking for, it was made for Ubuntu. I do have python3 installed on my Mac but it goes to /usr/bin/python3 and Mac automatically installs python, I want python3 to go to /usr/bin/python Running which python returns python not found which is weird, because python should be preinstalled on Mac. Any ideas how to fix this error, and is my way possible?

Thanks!

Studied answered 16/2, 2022 at 14:30 Comment(2)
if the question is about python why is not tagged as python? which python will try to find python 2.X but you have python 3. try which python3 or install python 2.XPrudhoe
I'm getting the same error, from what I can tell Apple removed python2.7 in their latest macos release which is what python was linked to before.Nonmetal
S
28

I encountered the same problem, but I solved it by executing the following command based on this issue.

sed -i -e 's/=python /=python3 /g' ~/Library/Arduino15/packages/esp32/hardware/esp32/*/platform.txt

https://github.com/espressif/arduino-esp32/issues/4717#issuecomment-1070801525

Shove answered 18/3, 2022 at 8:25 Comment(4)
I'm not sure if that's because of you're solution or because I reset my system files, but now it's working flawlessly, thank you very much!Studied
Worked on macOS Monterey with Arduino IDE 1.8.19!Rendezvous
This worked for me. I use the M5Stack package, so had to replace eps32 with m5stack.Morn
That worked for me, Arduino 1.8.19. M1 macbook pro. Sparkfun Esp32 ThingBordelon
T
0

python2 has been removed in MacOs Monterey 12.3. So the proper way is to reinstall python2 if you have an application that needs it. But in case that your current script would work with python3 you may try add a symlink. But you need to add in /usr/local/bin

sudo ln -s /path/to/python3 /usr/local/bin/python
Timothy answered 23/3, 2022 at 20:45 Comment(0)
B
0

Try this:

sudo ln -s `which python3` /usr/local/bin/python

or

sudo ln -s /usr/bin/python3 /usr/local/bin/python

MAC OS doesn't allow for symlinks in /usr/bin so you have to put the symlink in /usr/local/bin instead.

Biodynamics answered 14/5, 2022 at 15:58 Comment(0)
P
0

You can modify the PATH used by the Arduino IDE by setting it in its Info.plist file. This file may be found here: /Applications/Arduino.app/Contents/Info.plist. You can either edit this plist file using a plist editor (e.g. one that comes with Xcode) and add the PATH Environment variable e.g. by running:

open /Applications/Arduino.app/Contents/Info.plist

Or you can just open it in a text editor, and find the following lines:

<key>LSEnvironment</key>
<dict>

Below this line add an entry to specify the PATH - e.g. if you need to add /usr/local/bin:

<key>PATH</key>
<string>/sbin:/usr/bin:/usr/sbin:/usr/local/bin</string>

Save and close the plist file then open the Arduino IDE and it should now find python3. And the application will work as normal with its icon in the task manager.

Another quicker dirtier way

There's also a quicker, but less clean, way to have the Arduino IDE find python - you can just start the executable from the command line in a Terminal where you have already set the appropriate PATH (e.g. you can set the PATH: `export PATH="/bin:/sbin:/usr/local/bin:/usr/bin:/usr/sbin"`):
/Applications/Arduino.app/Contents/MacOS/Arduino

The Arduino IDE will start and you'll see all the log messages in the Terminal but the application Icon won't show in the task switcher or Dock (it will just show the generic black "exec" Terminal Icon) though it will work normally and will find python3.

Platform answered 26/7, 2024 at 7:52 Comment(0)
N
-1

Probably a soft link will do, try sudo ln -s /usr/bin/python3 /usr/bin/python

Nysa answered 17/2, 2022 at 12:56 Comment(1)
It results in: ln: /usr/bin/python: Operation not permittedStudied

© 2022 - 2025 — McMap. All rights reserved.