Does ESP32 require micropython?

I am using IDE 1.8.19 on OSX 10.13.6

I have used Board Manager to install the ESP32 by Espressif Systems.

I have selected "ESP32-WROOM-DA module" as my board.

When I attempt to compile any of the example code, I am getting an error "Error loading Python lib".

I have made no attempt install micropython as I do not plan on using it. I would assume that if it was a reqirement for compile tool chain than the board manager would have installed it automagically.

Is micropython a reqirement for ESP32 development? How does one install micropython on OSX 10.13.6

1 Like

The ESP32 boards use Python running on the PC to upload code to the board. It has nothing to do with microPython running on the board

Summary : you do not need to install microPython

I have no experience of MAC OS but the obvious thing to do would be to remove the ESP32 board definitions using the IDE and to install them again

You can develop in C++; even so, the ESP32 toolchain requires Python. In particular, it runs

  • esptool.py
  • gen_esp32part.py
  • gen_insights_package.py

with python3

macOS 10.13 (High Sierra) has been out of support for almost four years; from what I can tell, it came with python2 out of the box. So you may need to install python3 if you haven't already. If it is recent enough, it should come with pip, and with that you can install a possibly missing dependency: pySerial

Oops - seems I may have confuesed python & micropython.

But following kenb4 suggestion...
Installed hombrew
used homebrew to install python3
can now get a reply back from issuing "python3" command in terminal
still getting same error from IDE "Error loading Python library '/var/folders/......./libpython3.8.dylib'"

I'm not an Apple guy, but I think your issue is Arduino IDE compatibility with your (rather old) version of mac OSX.

See here for a workaround: https://stackoverflow.com/questions/72505908/esp32-core-update-problems

As noted above, your issue is with Python running on your host computer. The Arduino IDE uses some open source tools to load your compiled Arduino program on the ESP32 board and these tools are written in (not Micro) Python. MicroPython is a particular version of Python that is largely targeted to run on higher end microcontrollers including the ESP32.

The current macOS python3 doesn’t work on 10.13
(For no particularly good reason, imo.)
I get a more verbose error, perhaps because I have "verbose output" selected in preferences:

[55574] Error loading Python lib '/var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T/_MEILE4rr1/libpython3.8.dylib': dlopen: dlopen(/var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T/_MEILE4rr1/libpython3.8.dylib, 10): Symbol not found: ____chkstk_darwin
  Referenced from: /var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T/_MEILE4rr1/libintl.8.dylib (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib
 in /var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T/_MEILE4rr1/libintl.8.dylib

(This may be a consequence of things like esptool being built as "executables" containing their own python version, rather than using the system-installed python.)

Between the advice I have received here and my googling, I have accepted that I will not be able to devlope for the ESP32 on my old workhorse. Thank you everyone for you help.

Again, I'm not an Apple guy, but my understanding from the Stackoverflow link in my previous post is that ESP32 support on the older mac OSX version works if the older (version 1.0.6) ESP32 core is installed using the Arduino IDE board manager.

See this post for how to get the older core.

I have exerted some effort an I think I have the latest version of the ESP32 core working on my High Sierra Mac.

It requires some fiddling... Basically, we need to use the High Sierra version of Python3 instead of what comes packaged with the ESP32 board package...

First, do you have python3 on your mac? (Open a terminal window and type "python3", and see if it works.)

Yes, it replies with 3.12.4

OK; here's an attempt at a tutorial for a fix...
So far, it seems to compile an empty sketch for "many" of the ESP32 boards (including the Arduino Nano ESP32.)

Let me know if there are parts that are particularly unclear, or if you run into additional problems...


Using ESP32 Arduino in older MacOS

Problem Statment:

Recent ESP32 board packages fail to work on older versions of MacOSX (ie "High Sierra 10.13.x) It yields error messages like:

"Error loading Python library '/var/folders/..../libpython3.8.dylib'"

Analysis:

With verbose logging on (from Preferences), we see more details

... /Applications/Arduino...packages/esp32/tools/esptool_py/4.6\/esptool --chip esp32s3 elf2image ...

[64191] Error loading Python lib '/var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T/_MEIGDe0by/libpython3.8.dylib': ... : Library not loaded: @loader_path/libintl.8.dylib

  Reason: Incompatible library version: libpython3.8.dylib requires version 12.0.0 or later, but libintl.8.dylib provides version 11.0.0

Hypothesis:

"esptool" has been created as a "packaged" python script, including its own copy of a python interpreter (say, using "pyinstaller".)
Unfortunately, this was done using a version of Python that does not run on older versions of MacOSX (Apple made some changes in weird places, I think for "security purposes. Older MacOS doesn't support OS calls used by these changes, so programs compiled with "new" MacOS that use those system calls don't work on older MacOS.)

esptool is a simple CLI program, and ought not be dependent on OS version. All we should need to do is replace esptool with a version that doesn't have the new OS dependencies.

Procedure:

A certain familiarity with using the MacOS "Terminal" program will be helpful.

Installing Python3.

First, we must make sure that Python3 is installed on the Mac. Older MacOS includes Python2.7, which (almost certainly) won't work.
Open the Utilities/Terminal application, and type "python3" at the prompt. If it works, type Ctrl-D to exit.

If it doesn't work, Python3 can be downloaded from Python Releases for macOS | Python.org
Use the Python 3.12.4 MacOS 64bit universal installer, and run it after downloading. After this, typing "python3" in the terminal window should work. (This should install python3 without having to install the (very large) XTools package, which some instructions suggest.)

Installing ESPTOOL.

In the terminal window, type "pip3 install esptool"
And then "which esptool.py" to find out where it is.

> which esptool.py
/usr/local/bin/esptool.py

Connect to the esp32 board package (which you should have already installed, using the Arduino IDE.)

> cd /Users/xxxx/Library/Arduino15/packages/esp32

Use the "find" command to find all the instances of esptool:

> find . -name esptool
./esptool_py/4.5.1/esptool
./esptool_py/3.1.0/esptool
./esptool_py/2.6.1/esptool

Back these up, just in case:

> mv ./esptool_py/4.5.1/esptool ./esptool_py/4.5.1/esptool.old
> mv ./esptool_py/3.1.0/esptool ./esptool_py/3.1.0/esptool.old
> mv ./esptool_py/2.6.1/esptool ./esptool_py/2.6.1/esptool.old

For each of those, link them to the newly installed esptool.py

> ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/esptool.py ./esptool_py/4.5.1/esptool
> ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/esptool.py ./esptool_py/3.1.0/esptool
> ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/esptool.py ./esptool_py/2.6.1/esptool

(I don't know why there are so many. This MIGHT mean that some esp32 boards will work, and others won't.)

At this point, Arduino build of ESP32 builds should get further.
But there are NEW errors, complaining about "python3 not found in path" when trying to run gen_esp32part.py.

Python Not in PATH.

I don't know what the Arduino is using for a PATH that it can't find python3, but to fix this, it seems easiest to simply provide a more specific path.

python SHOULD be accessible via /usr/local/bin/python3. Check to make sure by typing "/usr/local/bin/python3" in the terminal window. If this doesn't work, even though just typing "python3" DOES work, you'll want to install a symbolic link:
Figure out where python3 actually lives with the "which python3" terminal command:

> which python3
/Volumes/MacOS/HD-Users/BillW/opt/anaconda3/bin/python3

Then do:

sudo ln -s /Volumes/MacOS/HD-Users/BillW/opt/anaconda3/bin/python3 /usr/local/bin/python3

(where the first argument is the results of the "which" command.)

Now, navigate to the location of your "platforms." Probably ...username/Library/Arduino15/packages/ (You may have to take steps to get to "Library" , since it's normally Hidden.") We need to edit the esp32 platform file (probably ...packages/esp32/hardware/esp32/3.0.2/platform.txt and ...packages/arduino/esp32/2.0.13/platform.txt) using a plain text editor (textedit will work.)
Just change all the occurances of "python3" to "/usr/local/bin/python3" (probably not all of them need to be changed - some are for linux - but it won't hurt anything...)

And that should do it.

2 Likes

THIS WORKS!

Thank you for such a detailed and well written procedure. As I performed each step, they closley matched your expected result which is always reassuring.. My notes follow...

Started with a fresh install of OSX High Sierra v10.13.6
Fresh install of Arduino v1.8.19
Fresh install of CH34x drivers for CH340 chip (v1.6)
Fresh install of SiLabs CP210x drivers (v6.0.2)

After installing Python v3.12.4 I had no reply from “which esptool.py”
Rebooted IMAC now replies “/Library/Frameworks/Python.framework/Versions/3.12/bin/esptool.py”
After creating symbolic links Arduino errors “python3 not found path” (as you expected)

“/usr/local/bin/python3” does initiate python environment
“/python3” also initiates python environment
“Which python3” results with “/Library/Framework/Python.framework/Versions/3.12/bin/python3”

Changed 10 occurrences of “python3” to “/usr/local/bin/python3/“ in “…/packages/esp32/…”
Didn’t have “…/packages/arduino/esp32…..”

Example programs now compile and upload.

Thank you so much for your time and effort. You are a legend.