Hi - Using ESP32 with either Arduino IDE 2.3.2 or VSCode with Arduino extension under MacOS. No problems until the other day, all of a sudden all my compiles give this error:
Error during build: fork/exec /usr/local/bin/python3: exec format error
I've been using ESP32 Core 2.017 until I can update some of my libraries that won't compile under Core 3.0+, but updating temporarily to 3.04 generates the same error.
Seems like a Python3 error or ESP Core error, not Arduino IDE, but don't know how to analyze this. Also occurs when using VSCode with Arduino extension.
Any ideas how to fix this? Thanks...
Hi @chicoDaMan. It looks like you have an installation of Python that was built for Linux, and so can't run on your macOS machine.
I'm not sure how you might have gotten that on your computer. As you guessed, it is not anything specific to Arduino IDE (Arduino IDE does install some tool dependencies, but it installs them to a dedicated location, not under /usr/local/bin
). Do you remember what you did to install Python on your computer?
As a general overview, the solution will be to remove the bad installation of Python. You might already have another good installation of Python (I think most people end up with one as part of their stock macOS installation because of XCode), which would then be used if the bad installation at /usr/local/bin/python3
was removed (/usr/local/bin
is probably first in your system PATH before the location of the good installation).
Thanks for the quick reply.
I found the Python3 installation at the referenced location (actually an alias which pointed at a Homebrew cask). I did:
brew uninstall python@3.12
brew doctor // (to analyze the remains of the installation)
brew cleanup // (to remove the broken symlinks)
...to get rid of it, and now things compile again. Yay!
Just before I did that, I saw that the Python 3.12 alias at that location was modified today about 2 hours before I discovered this error. Does Homebrew do autoinstall and autoupdate? If so, will I likely see this error again?
As a general overview, the solution will be to remove the bad installation of Python.
Did that just before I saw your message. You were correct about that.
You might already have another good installation of Python (I think most people end up with one as part of their stock macOS installation because of XCode), which would then be used if the bad installation at /usr/local/bin/python3
was removed .
Yes, the original MacOS Python installation is there and shouldn't be messed with, according to everything I've read.
(/usr/local/bin
is probably first in your system PATH before the location of the good installation).
Yes, that makes sense. Not sure if I have other packages that require Python 3.12 but now that I'm aware of this I can address those issues as they arise.
I'll keep an eye on this moving forward and if Homebrew re-installs Python 3.12 again (and it causes the same problem) I'll post back here, if only to help others and myself to better understand this.
Thanks again!
Great work on fixing the problem!
I'm not very knowledgeable in this area, but I very much doubt that it will automatically install an application after you uninstalled it.
Yeah, definitely don't mess with it, but it will be fine to use it passively.
When we are doing Python development work we often want to have complete control over which version of Python we are using and its dependencies environment. However, the way Python is used by the "esp32" boards platform is quite flexible and you can get away with pretty much any Python 3.x interpreter that happens to be installed on the system. The "esp32" boards platform only passively uses the interpreter to execute a script and doesn't make any changes to the Python environment so the platform using the system installation of Python won't "mess" with it in any way.
Thanks for the helpful info. I like playing with Python but I'm no expert. Over the years I've accumulated multiple versions as at times different projects require different versions. I know my Python environment has gotten kind of messy.
One more question. You said:
How did you determine that? Solely from the error message, or have you previous experience with this issue? I haven't done a manual installation of any Python in a long time so I'm baffled how it might have happened...
As I mentioned above, you don't need to worry about it for this specific use case as long as there is a functional Python 3.x in the system PATH somewhere. However, for developing Python projects I highly recommend Poetry, which makes it very easy to set up an isolated and well managed Python dependencies environment for each project:
The Arduino Tooling team that develops the Arduino development tools and associated projects uses Poetry in all our projects that involve Python.
Yeah, I just Googled the error message and found some Stack Exchange questions that turned out to be caused by that. In theory it might be a build for some other architecture, but I don't think it could be Windows and if it was an Apple Silicon vs x86 ("Intel") build situation I think that would generate a different error message ("bad CPU type in executable
"), so that doesn't leave many options.
Maybe the Brew formula maintainers made a mistake? I did a quick look through the issue tracker and didn't spot anything about it so I'm a bit doubtful about that hypothesis.