SOLVED: MacOS 10.14.6: Failed to execute script 'esptool' due to unhandled exception! – Software Issue in IDE using an Espressif ESP32-S2-WROVER board

The issue could be resolved thanks to the answer provided by @ptillisch – I had to tweak it a little, so if you want to see that, go to this reply: SOLVED: MacOS 10.14.6: Failed to execute script 'esptool' due to unhandled exception! – Software Issue in IDE using an Espressif ESP32-S2-WROVER board - #6 by jsteiwer

–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Hello,

I'm using an ESP32-S2-WROVER board (listed as ESP32S2 Dev Module) together with the Espressif JSON file (https://dl.espressif.com/dl/package_esp32_index.json), drivers for the connection (https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/establish- serial-connection.html) and the following Adafruit libraries: Adafruit BME280 Library, Adafruit Unified Sensor Driver, and Adafruit BusIO Library.

The board is recognized by my laptop and I can communicate with it, but when I try to verify my code, I get the following error:

Traceback (most recent call last):
File "esptool/loader.py", line 57, in <module>
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "serial/tools/list_ports.py", line 31, in <module>
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "serial/tools/list_ports_posix.py", line 33, in <module>
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "serial/tools/list_ports_osx.py", line 26, in <module>
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "ctypes/__init__.py", line 7, in <module>
ImportError: dlopen(/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIKr1gsb/lib-dynload/_ctypes.cpython-38-darwin.so, 2): Symbol not found: _ffi_closure_alloc
Referenced from: /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIKr1gsb/lib-dynload/_ctypes.cpython-38-darwin.so (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libffi.dylib
in /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIKr1gsb/lib-dynload/_ctypes.cpython-38-darwin.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool.py", line 31, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "esptool/__init__.py", line 41, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "esptool/cmds.py", line 14, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "esptool/bin_image.py", line 14, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "esptool/loader.py", line 62, in <module>
AttributeError: module 'sys' has no attribute 'VERSION'
[1636] Failed to execute script 'esptool' due to unhandled exception!

exit status 1

Compilation error: exit status 1

I have tried updating to the latest Python version, updating gettext, installing esptool, and updating ffi - all attempts have been futile so far.

The sketch I'm trying to verify is this one:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // over I2C

unsigned long delayTime;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(F("BME280 test"));

  bool status;

  Serial.println(F("Checking and starting the BME280..."));
  status = bme.begin(0x76);

  if (!status) {
    while (1);
      Serial.println(F("Could not find a valid BME280 sensor, check wiring!"));
      delay(1000);
  }

  Serial.println(F("BME280 present and started."));
  delayTime = 1000;

  Serial.println();
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print(F("Temperature = "));
  Serial.print(bme.readTemperature());
  Serial.println(F(" *C"));

  Serial.print(F("Pressure = "));
  Serial.print(bme.readPressure() / 100.0F);
  Serial.println(F(" hPa"));

  Serial.print(F("Approx. Altitude = "));
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(F(" m"));

  Serial.print(F("Humidity = "));
  Serial.print(bme.readHumidity());
  Serial.println(F(" %"));

  Serial.println();

  delay(5000);
}

The IDE is Version 2.2.2-nightly-20230918 (2.2.2-nightly-20230918), and I'm running it on MacOS 10.14.6 (I cannot update my OS to a higher version).

If anyone has an idea what could be done, please let me know, I'll try it.

Thank you in advance for your comments and help! :heart:

PS: It would be nice if new users could also upload files, I think it would make things easier for both sides.

So give this version of the IDE a try
https://downloads.arduino.cc/arduino-1.8.19-macosx.zip

Thank you for the suggestion. I installed it, installed all the libraries I needed, and made sure to add the JSON file but again it did not work. The new error message looks like this:

Arduino: 1.8.19 (Mac OS X), Board: "ESP32S2 Dev Module, Disabled, Disabled, Disabled, Disabled, UART0, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi), QIO, 80MHz, 4MB (32Mb), 921600, None, Disabled"

/private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/hardware -hardware /Users/juliasteiwer/Library/Arduino15/packages -tools /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/tools-builder -tools /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/juliasteiwer/Library/Arduino15/packages -built-in-libraries /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/libraries -libraries /Users/juliasteiwer/Documents/Arduino/libraries -fqbn=esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -vid-pid=0000_0000 -ide-version=10819 -build-path /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006 -warnings=none -build-cache /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_cache_122304 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.dfu-util.path=/Users/juliasteiwer/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/Users/juliasteiwer/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mklittlefs.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.openocd-esp32.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20221026.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.esptool_py.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.esptool_py-4.5.1.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mkspiffs.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -verbose /Users/juliasteiwer/Documents/Arduino/sketch_sep19a/sketch_sep19a.ino
/private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/hardware -hardware /Users/juliasteiwer/Library/Arduino15/packages -tools /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/tools-builder -tools /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/juliasteiwer/Library/Arduino15/packages -built-in-libraries /private/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/AppTranslocation/5072F954-3BB1-44F7-B9BA-CEFB880309C3/d/Arduino.app/Contents/Java/libraries -libraries /Users/juliasteiwer/Documents/Arduino/libraries -fqbn=esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -vid-pid=0000_0000 -ide-version=10819 -build-path /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006 -warnings=none -build-cache /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_cache_122304 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.riscv32-esp-elf-gdb.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gdb-11.2_20220823.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.riscv32-esp-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.dfu-util.path=/Users/juliasteiwer/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.dfu-util-0.11.0-arduino5.path=/Users/juliasteiwer/Library/Arduino15/packages/arduino/tools/dfu-util/0.11.0-arduino5 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mklittlefs.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.openocd-esp32.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20221026.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/openocd-esp32/v0.11.0-esp32-20221026 -prefs=runtime.tools.xtensa-esp-elf-gdb.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.xtensa-esp-elf-gdb-11.2_20220823.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp-elf-gdb/11.2_20220823 -prefs=runtime.tools.esptool_py.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.esptool_py-4.5.1.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-esp-2021r2-patch5-8.4.0.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0 -prefs=runtime.tools.mkspiffs.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/mkspiffs/0.2.3 -verbose /Users/juliasteiwer/Documents/Arduino/sketch_sep19a/sketch_sep19a.ino
Using board 'esp32s2' from platform in folder: /Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11
Using core 'esp32' from platform in folder: /Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11
bash -c "[ ! -f \"/Users/juliasteiwer/Documents/Arduino/sketch_sep19a\"/partitions.csv ] || cp -f \"/Users/juliasteiwer/Documents/Arduino/sketch_sep19a\"/partitions.csv \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/partitions.csv"
bash -c "[ -f \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/partitions.csv ] || [ ! -f \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32s2\"/partitions.csv ] || cp \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32s2\"/partitions.csv \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/partitions.csv"
bash -c "[ -f \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/partitions.csv ] || cp \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11\"/tools/partitions/default.csv \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/partitions.csv"
bash -c "[ -f \"/Users/juliasteiwer/Documents/Arduino/sketch_sep19a\"/bootloader.bin ] && cp -f \"/Users/juliasteiwer/Documents/Arduino/sketch_sep19a\"/bootloader.bin \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/sketch_sep19a.ino.bootloader.bin || ( [ -f \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32s2\"/bootloader.bin ] && cp \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/variants/esp32s2\"/bootloader.bin \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/sketch_sep19a.ino.bootloader.bin || \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1\"/esptool --chip esp32s2 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o \"/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/arduino_build_841006\"/sketch_sep19a.ino.bootloader.bin \"/Users/juliasteiwer/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/tools/sdk/esp32s2\"/bin/bootloader_qio_80m.elf )"
Traceback (most recent call last):
  File "esptool/loader.py", line 57, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "serial/tools/list_ports.py", line 31, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "serial/tools/list_ports_posix.py", line 33, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "serial/tools/list_ports_osx.py", line 26, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "ctypes/__init__.py", line 7, in <module>
ImportError: dlopen(/var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIF1nzTl/lib-dynload/_ctypes.cpython-38-darwin.so, 2): Symbol not found: _ffi_closure_alloc
  Referenced from: /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIF1nzTl/lib-dynload/_ctypes.cpython-38-darwin.so (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libffi.dylib
 in /var/folders/nv/h2gr6p0s6hd1ccjw7l_tr5ym0000gn/T/_MEIF1nzTl/lib-dynload/_ctypes.cpython-38-darwin.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "esptool.py", line 31, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "esptool/__init__.py", line 41, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "esptool/cmds.py", line 14, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "esptool/bin_image.py", line 14, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "esptool/loader.py", line 62, in <module>
AttributeError: module 'sys' has no attribute 'VERSION'
[20846] Failed to execute script 'esptool' due to unhandled exception!
exit status 1
Fehler beim Kompilieren für das Board ESP32S2 Dev Module.

1 Like

I have also followed this tutorial

to see if I had correctly considered all prerequisites but I received the same error message as before.

Could the problem lie with Python? I have Python 3.8.10 installed (used Homebrew) and Python 3.10 (official Python site) but if I just enter the Python command in the terminal, it tells me that 2.7.16 is the default version. Could this cause the error? If yes, what can I do to keep 2.7.16 on my laptop and just making 3.8.10 the default? Thank you already in advance!

Hi @jsteiwer.

Unfortunately I think this is the cause of the error. As discussed here:

Some more advanced solutions are discussed at that link.

Normally I would suggest the more simple (though far from ideal) solution of using an older version (1.0.6) of the "esp32" boards platform from before the time when the incompatibility was introduced. However, support for the ESP32-S2 was introduced after that (in the 2.0.0 release of the platform) so that workaround won't be useful for your ESP32-S2 board.

Hi, thank you very much for your reply!

I tried the solution proposed by zfields (esptool.py in 2.0.0 seems to require macOS 10.15 minimum, fails on 10.13 · Issue #5639 · espressif/arduino-esp32 · GitHub).

I had to use a different solution for setting Python3 as the default (see Make python3 as my default python on Mac - Stack Overflow) and after, it works fine until step 8 of zfield's answer. There, I get the following message in the terminal:

426 INFO: PyInstaller: 5.13.2
426 INFO: Python: 3.8.10
439 INFO: Platform: macOS-10.14.6-x86_64-i386-64bit
440 INFO: wrote /Users/juliasteiwer/esptool.spec
script '/Users/esptool.py' not found

I then installed esptool with pip install esptool in hopes of solving the issue.

Changing the version number from step 9 to my version, I received the message cp: dist/esptool: No such file or directory – I checked my files manually and found that the esptool file exists at the path /Users/juliasteiwer/esptool/esptool_py/dist.

I tried verifying the code again.
For Arduino 1.8.19 and Arduino IDE Version: 2.2.2-nightly-20230918, I get this error:
fork/exec /Users/juliasteiwer/Library/Arduino15/packages/esp32/tools/esptool_py/4.5.1/esptool: no such file or directory

So, since the copying in the terminal had not worked, I manually copied and pasted the esptool file into the correct folder.

Now, it works perfectly fine!

To make this solution easier to find for others please modify the titel of the thread so the titel contains

This makes visible already in the headline what was the problem to what specific MacOS-Version

best regards Stefan

1 Like

Thank you for the reminder, just updated the title!

1 Like

I'm glad it is working now. Thanks for taking the time to post an update with your solution. I'm sure others who have the same problem and find this forum topic during their searches for a solution will be very grateful.

Regards,
Per

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.