Itamar Cohen
Itamar Cohen

Reputation: 350

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

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!

Upvotes: 11

Views: 8658

Answers (5)

Pierz
Pierz

Reputation: 8168

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.

Upvotes: 0

Charles Libby
Charles Libby

Reputation: 1

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.

Upvotes: 0

Pedram Tadayoni
Pedram Tadayoni

Reputation: 171

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

Upvotes: 0

Haruka Yamamoto
Haruka Yamamoto

Reputation: 381

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

Upvotes: 28

balun
balun

Reputation: 1324

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

Upvotes: -1

Related Questions