Example Project - Espressif ESP32-S2 Programming Manual

Table of Contents

Advertisement

Chapter 4. API Guides
Setting up the Python Interpreter
ESP-IDF works well with all supported Python versions. It should work out-of-box even if you have a legacy system
where the default python interpreter is still Python 2.7, however, it is advised to switch to Python 3 if possible.
idf.py and other Python scripts will run with the default Python interpreter, i.e. python. You can switch to a
different one like python3 $IDF_PATH/tools/idf.py ..., or you can set up a shell alias or another script
to simplify the command.
If using CMake directly, running cmake -D PYTHON=python3 ... will cause CMake to override the default
Python interpreter.
If using an IDE with CMake, setting the PYTHON value as a CMake cache override in the IDE UI will override the
default Python interpreter.
To manage the Python version more generally via the command line, check out the tools
let you change the default Python version.
Possible issues
The user of idf.py may sometimes experience ImportError described below.
Traceback (most recent call last):
File "/Users/user_name/e/esp-idf/tools/kconfig_new/confgen.py", line 27, in
<module>
import kconfiglib
ImportError: bad magic number in 'kconfiglib': b'\x03\xf3\r\n'
The exception is often caused by .pyc files generated by different Python versions. To solve the issue run the
following command:
idf.py python-clean

4.4.3 Example Project

An example project directory tree might look like this:
- myProject/
- CMakeLists.txt
- sdkconfig
- components/ - component1/ - CMakeLists.txt
- main/
- build/
This example "myProject"contains the following elements:
• A top-level project CMakeLists.txt file. This is the primary file which CMake uses to learn how to build
the project; and may set project-wide CMake variables. It includes the file
implements the rest of the build system. Finally, it sets the project name and defines the project.
•"sdkconfig"project configuration file. This file is created/updated when idf.py menuconfig runs, and
holds configuration for all of the components in the project (including ESP-IDF itself). The "sdkconfig"file
may or may not be added to the source control system of the project.
Espressif Systems
- Kconfig
- src1.c
- component2/ - CMakeLists.txt
- Kconfig
- src1.c
- include/ - component2.h
- CMakeLists.txt
- src1.c
- src2.c
1273
Submit Document Feedback
pyenv
or virtualenv. These
/tools/cmake/project.cmake
Release v4.4
which

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Table of Contents

Save PDF