espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
685 stars 155 forks source link

No module named 'matter_idl' (CON-558) #455

Closed xiaozhengrui closed 1 year ago

xiaozhengrui commented 1 year ago

Traceback (most recent call last): File "/home/janray/esp-matter/examples/light/build/esp-idf/chip/../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/scripts/codegen.py", line 28, in from matter_idl.matter_idl_parser import CreateParser ModuleNotFoundError: No module named 'matter_idl'

shubhamdp commented 1 year ago

@xiaozhengrui This happens if you have forgot to export the idf environment before sourcing esp-matter/export.sh.

This is similar this FAQ, please follow the steps mentioned threre.

xiaozhengrui commented 1 year ago

I tried to follow the steps below to address this issue, but the same error still occurred

cd esp-idf source ./export.sh

cd esp-matter python3 -m pip install -r requirements.txt

Now examples will build without any error

cd examples/... idf.py build

xiaozhengrui commented 1 year ago

[1067/1219] Performing build step for 'chip_gn' FAILED: esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build esp-idf/chip/lib/libCHIP.a /home/janray/esp-matter/examples/light/build/esp-idf/chip/chip_gn-prefix/src/chip_gn-stamp/chip_gn-build /home/janray/esp-matter/examples/light/build/esp-idf/chip/lib/libCHIP.a cd /home/janray/esp-matter/examples/light/build/esp-idf/chip && ninja esp32 [1/478] c++ obj/third_party/connectedhomeip/src/credentials/libCredentials.DeviceAttestationCredsProvider.cpp.o [2/478] c++ obj/third_party/connectedhomeip/src/crypto/libChipCrypto.RandUtils.cpp.o [3/478] c++ obj/third_party/connectedhomeip/src/credentials/tests/libCertTestVectors.CHIPAttCert_test_vectors.cpp.o [4/478] c++ obj/third_party/connectedhomeip/src/credentials/tests/libCertTestVectors.CHIPCert_error_test_vectors.cpp.o [5/478] c++ obj/third_party/connectedhomeip/src/credentials/tests/libCertTestVectors.CHIPCert_unit_test_vectors.cpp.o [6/478] c++ obj/third_party/connectedhomeip/src/crypto/libChipCrypto.RawKeySessionKeystore.cpp.o [7/478] c++ obj/third_party/connectedhomeip/src/credentials/libCredentials.DeviceAttestationConstructor.cpp.o [8/478] c++ obj/third_party/connectedhomeip/src/crypto/libChipCrypto.PersistentStorageOperationalKeystore.cpp.o [9/478] ACTION //third_party/connectedhomeip/src/controller/data_model:data_model_codegen_codegen(//third_party/connectedhomeip/config/esp32/toolchain:esp32) FAILED: gen/third_party/connectedhomeip/src/controller/data_model/app/PluginApplicationCallbacks.h gen/third_party/connectedhomeip/src/controller/data_model/app/callback-stub.cpp python ../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/third_party/pigweed/repo/pw_build/py/pw_build/python_runner.py --gn-root ../../../../../connectedhomeip/connectedhomeip/config/esp32/ --current-path ../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/controller/data_model --default-toolchain=//third_party/connectedhomeip/config/esp32/toolchain:esp32 --current-toolchain=//third_party/connectedhomeip/config/esp32/toolchain:esp32 --capture-output --python-dep-list-files gen/third_party/connectedhomeip/src/controller/data_model/data_model_codegen_codegen_metadata_path_list.txt -- ../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/scripts/codegen.py --generator cpp-app --output-dir gen/third_party/connectedhomeip/src/controller/data_model --expected-outputs gen/third_party/connectedhomeip/src/controller/data_model/data_model_codegen.expected.outputs ../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/src/controller/data_model/controller-clusters.matter Traceback (most recent call last): File "/home/janray/esp-matter/examples/light/build/esp-idf/chip/../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/scripts/codegen.py", line 28, in from matter_idl.matter_idl_parser import CreateParser ModuleNotFoundError: No module named 'matter_idl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/janray/esp-matter/examples/light/build/esp-idf/chip/../../../../../connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/scripts/codegen.py", line 32, in from matter_idl.matter_idl_parser import CreateParser File "/home/janray/esp-matter/connectedhomeip/connectedhomeip/config/esp32/third_party/connectedhomeip/scripts/py_matter_idl/matter_idl/matter_idl_parser.py", line 7, in from lark import Lark ModuleNotFoundError: No module named 'lark'

shubhamdp commented 1 year ago

Can you try source $IDF_PATH/export.sh && python3 -m pip install lark, since above did not work.

xiaozhengrui commented 1 year ago

I try to do source $IDF_PATH/export.sh && python3 -m pip install lark, but the problem still exists

janray@Janray:~/esp-idf$ source $IDF_PATH/export.sh Detecting the Python interpreter Checking "python" ... Python 3.10.6 "python" has been detected Adding ESP-IDF tools to PATH... Using Python interpreter in /home/janray/.espressif/python_env/idf4.4_py3.10_env/bin//python Checking if Python packages are up to date... Python requirements from /home/janray/esp-idf/requirements.txt are satisfied. Added the following directories to PATH: /home/janray/esp-idf/components/esptool_py/esptool /home/janray/esp-idf/components/espcoredump /home/janray/esp-idf/components/partition_table /home/janray/esp-idf/components/app_update Done! You can now compile ESP-IDF projects. Go to the project directory and run:

idf.py build

janray@Janray:~/esp-idf$ python3 -m pip install lark Defaulting to user installation because normal site-packages is not writeable Collecting lark Using cached lark-1.1.5-py3-none-any.whl (107 kB) Installing collected packages: lark Successfully installed lark-1.1.5

xiaozhengrui commented 1 year ago

Pip installation of lark will default to the local path of Python and change it to the Python environment under esp idf. I will directly copy lark to this path as follows, and then execute idf.py build to compile successfully

Cp - r~/. local/lib/Python 3.10/site packages/stringcase 1.2.0. dist info~/. espressif/Python Env/idf4.4 Py3.10_ Env/lib/python3.10/site packages

Cp - r~/. local/lib/Python 3.10/site packages/stringcase. py~/. espressif/Python Env/idf4.4 Py3.10_ Env/lib/python3.10/site packages

shubhamdp commented 1 year ago

Defaulting to user installation because normal site-packages is not writeable

Above line from your log is trying to say the same that its not able to install lark to idf environment.

Sure, the copying it would have worked. But, I am still not sure, why it did not install it into idf's environment.

Can you please share the output of which -a python3 after souring the esp-idf/export.sh.

If possible can you try: Pick the Python3 binary from idf's environment, it will look like /Users/shubhampatil/.espressif/python_env/idf4.4_py3.11_env/bin/python3 and then try installing lark with this python.

/Users/shubhampatil/.espressif/python_env/idf4.4_py3.11_env/bin/python3 -m pip install lark
shubhamdp commented 1 year ago

@xiaozhengrui If the issue is resolved can you please close this.