PlatformIO Community

How to import Python modules esp-idf?

To test the executable code, I need to run a Python script from the official ESP-IDF examples folder.
When I run the script, I get an error.

Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.

Traceback (most recent call last):
  File "", line 4, in <module>
    import ttfw_idf
ModuleNotFoundError: No module named 'ttfw_idf'

What should I do?
Thank you.

Is python the same Python as used by PlatformIO? In a PlatformIO CLI, does pio system info --> “Python Executable” piont to the same Python? If not, please always use the Python installation that PlatformIO uses.

Usually when platform-espressif32 needs to install Python library dependencies when building ESP-IDF, it calls the python installation’s pip library manager to install the library.

The folder C:\Users\<user>\.platformio\packages\framework-espidf\tools\ci\python_packages has the Python packages needed here, including ttfw_idf but also others tiny_test_fw and whatever).


However, that is not applicable here, since they aren’t pip-installable libraries (no or anything). There is just a special script that adds the folder to the PYTHONPATH so that the libraries are seen.

So you must do the same somehow through system environment variables.

However since all the files as .sh files, I doubt that the ESP-IDF’s CI system works on Windows, but rather only on Linux. You should ask in if there are problems with that.

I understood. Thank you. I will be forced to install esp-idf environment for Windows separately and run scripts there. This is not entirely correct and uncomfortable to keep two environments in the system.