platformio-home icon indicating copy to clipboard operation
platformio-home copied to clipboard

Cannot create a new ESP32 based project on Apple Silicon host (ModuleNotFoundError: No module named 'chardet')

Open clarencelocke opened this issue 1 year ago • 1 comments

PIO Core Call Error: "The following files/directories have been created in ~/Documents/PlatformIO/Projects/MyESP32Project include - Put project header files here lib - Put project specific (private) libraries here src - Put project source files here platformio.ini - Project Configuration File Resolving esp32dev dependencies... Already up-to-date. Updating metadata for the vscode IDE...

UserSideException: Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html PLATFORM: Espressif 32 (5.4.0) > Espressif ESP32 Dev Module HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:

  • framework-espidf @ 3.40405.230623 (4.4.5)
    • tool-cmake @ 3.16.4
    • tool-esptoolpy @ 1.40400.0 (4.4.0)
    • tool-ninja @ 1.9.0
    • toolchain-esp32ulp @ 1.23500.220830 (2.35.0)
    • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
  • Reading CMake configuration...
  • -- Found Git: /usr/bin/git (found version "2.39.3 (Apple Git-145)")
  • -- The C compiler identification is GNU 8.4.0
  • -- The CXX compiler identification is GNU 8.4.0
  • -- The ASM compiler identification is GNU
  • -- Found assembler: /Users/clarence/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
  • -- Check for working C compiler: /Users/clarence/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
  • -- Check for working C compiler: /Users/clarence/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc -- works
  • -- Detecting C compiler ABI info
  • -- Detecting C compiler ABI info - done
  • -- Detecting C compile features
  • -- Detecting C compile features - done
  • -- Check for working CXX compiler: /Users/clarence/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++
  • -- Check for working CXX compiler: /Users/clarence/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-g++ -- works
  • -- Detecting CXX compiler ABI info
  • -- Detecting CXX compiler ABI info - done
  • -- Detecting CXX compile features
  • -- Detecting CXX compile features - done
  • -- Project is not inside a git repository, or git repository has no commits; will not use 'git describe' to determine PROJECT_VER.
  • -- Building ESP-IDF components for target esp32
  • -- Configuring incomplete, errors occurred!
  • See also "/Users/clarence/Documents/PlatformIO/Projects/MyESP32Project/.pio/build/esp32dev/CMakeFiles/CMakeOutput.log".
  • fatal: not a git repository (or any of the parent directories): .git
  • CMake Error at /Users/clarence/.platformio/packages/[email protected]/tools/cmake/build.cmake:463 (message):
  • Traceback (most recent call last):
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/requests/compat.py", line 11, in
  • import chardet
  • ModuleNotFoundError: No module named 'chardet'
  • During handling of the above exception, another exception occurred:
  • Traceback (most recent call last):
  • File "", line 198, in _run_module_as_main
  • File "", line 88, in _run_code
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/idf_component_manager/prepare_components/main.py", line 4, in
  • from .prepare import main
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/idf_component_manager/prepare_components/prepare.py", line 18, in
  • from ..core import ComponentManager
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/idf_component_manager/core.py", line 18, in
  • import requests
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/requests/init.py", line 45, in
  • from .exceptions import RequestsDependencyWarning
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/requests/exceptions.py", line 9, in
  • from .compat import JSONDecodeError as CompatJSONDecodeError
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/requests/compat.py", line 13, in
  • import charset_normalizer as chardet
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/init.py", line 24, in
  • from .api import from_bytes, from_fp, from_path, is_binary
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/api.py", line 5, in
  • from .cd import (
  • File "/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/cd.py", line 14, in
  • from .md import is_suspiciously_successive_range
  • ImportError:
  • dlopen(/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so,
  • 0x0002): tried:
  • '/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so'
  • (mach-o file, but is an incompatible architecture (have 'arm64', need
  • 'x86_64')),
  • '/System/Volumes/Preboot/Cryptexes/OS/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so'
  • (no such file),
  • '/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-darwin.so'
  • (mach-o file, but is an incompatible architecture (have 'arm64', need
  • 'x86_64'))
  • Call Stack (most recent call first):
  • /Users/clarence/.platformio/packages/[email protected]/tools/cmake/project.cmake:393 (idf_build_process)
  • CMakeLists.txt:3 (project)
  • ========================== [FAILED] Took 2.60 seconds =========================="

clarencelocke avatar Mar 30 '24 17:03 clarencelocke

Not to be unsympathetic - hey, we're all users trying to help each other out - but lots of us compile ESP32 code (RV and LX6/LX7) on Apple Silicon hosts pretty often without issue. So not to sound like one of those antatonistic support calls, but maybe it's not all them, but maybe a dash of you.

You didn't include a reproducible test case so anyone else can look at it to see what you were doing differently than the rest of the world. No fetchable repo to clone or steps to follow means that the helpers are left to try to guess what makes your invocation "special". That's rarely well spent effort for anyone but you. (Sorry.)

It catches my eye that there's a lot of Python barf in your stack trace. I don't use Python in my embedded builds. I can't tell if that Python is even yours or what comes with a system or what should come with a system but didn't or whatever. (Have I blown my cover as not a fan of the Python ecosystem?) Not saying there's cause/effect there, but maybe that's a hint on where to start digging. There are Pythonic errors that are really really similar going back at least sixe years. Ex: https://stackoverflow.com/questions/51775462/python-3-7-import-requests-returns-chardet-error Maybe there's a hint in there somewhere.

In short, just as a bystander that's trying to throw a fellow dev a life jacket, to me this looks like either a question that's not asked well enough to actually get the help you need OR some kind of Python-specific library (chardet ?) that's being used by ... something that isn't being found. (Resolving this latter case is about half of the development time I've spent on Python. Something I didn't know I needed wasn't installed for this specific version of Python that's hidden deeply on the system, but in a different versino of Python than the one that's in my $PATH...but I'm not bitter, noooooo. :-) Cross development (writing code on a Real Computer for a Tiny Computer) makes this issue much harder to work through because the Python you can "see" may not even be related to, say, '/Users/clarence/.platformio/penv/.espidf-4.4.5/lib/python3.12/site-packages/charset_normalizer' and friends (that path may or may not have anything to do with anything - it's just an example) which can make "normal" debugging vs. embedded download of scripting languages all the more frustrating to work through. 'Chardet' may work perfectly normally on native systems but be missing/malformed on the embedded/cross dev environment to lead to this kind of thing.

Even if I haven't directly helped (sorry /shruggie) hopefully I've helped improve the quality of the question enough (reproducible steps on dev issues rock! A dev can't "fix" what they can't see...) to help move the conversation along once you're at the top of their queue. It looks like there's a backlog of a few thousand between the rise of popularity of Platformio and the homeland of the project's principal developers being regularly bombed.

May The Source Be With You! (And certainly with the PlatformIO team!)

robertlipe avatar Apr 02 '24 05:04 robertlipe