Page 1 of 1

Cannot run esp_prov.py: No module named 'google'

Posted: Mon Jul 15, 2024 9:35 pm
by fearless_fool
Using a fresh build of the ESP IDF 5.2 shell under Windows 11, I have built and flashed the code in

https://github.com/espressif/esp-idf/tr ... i_prov_mgr

on an ESP32-C3. It compiles and runs without error.

Now I would like to communicate with the wifi_prov_mgr app using the esp_prov.py code from:
https://github.com/espressif/esp-idf/tr ... sp_prov.py

But:

Code: Select all

PS C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov> python esp_prov.py --transport ble --service_name PROV_3E4530 --sec_ver 2 --sec2_username wifiprov --sec2_pwd abcd1234 --ssid xxxxxxxxx --passphrase xxxxxxxxxxxxx
Traceback (most recent call last):
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\esp_prov.py", line 17, in <module>
    import prov
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\prov\__init__.py", line 6, in <module>
    from .wifi_ctrl import *  # noqa F403
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\prov\wifi_ctrl.py", line 7, in <module>
    import proto
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\proto\__init__.py", line 27, in <module>
    constants_pb2 = _load_source('constants_pb2', idf_path + '/components/protocomm/python/constants_pb2.py')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\proto\__init__.py", line 20, in _load_source
    spec.loader.exec_module(module)
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/components/protocomm/python/constants_pb2.py", line 5, in <module>
    from google.protobuf.internal import builder as _builder
ModuleNotFoundError: No module named 'google'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov\esp_prov.py", line 26, in <module>
    import prov
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/tools/esp_prov\prov\__init__.py", line 6, in <module>
    from .wifi_ctrl import *  # noqa F403
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/tools/esp_prov\prov\wifi_ctrl.py", line 7, in <module>
    import proto
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/tools/esp_prov\proto\__init__.py", line 27, in <module>
    constants_pb2 = _load_source('constants_pb2', idf_path + '/components/protocomm/python/constants_pb2.py')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/tools/esp_prov\proto\__init__.py", line 20, in _load_source
    spec.loader.exec_module(module)
  File "C:\Espressif\frameworks\esp-idf-v5.2.2/components/protocomm/python/constants_pb2.py", line 5, in <module>
    from google.protobuf.internal import builder as _builder
ModuleNotFoundError: No module named 'google'
PS C:\Espressif\frameworks\esp-idf-v5.2.2\tools\esp_prov> 
What am I missing? Or what additional info would help debug the problem?

Re: Cannot run esp_prov.py: No module named 'google'

Posted: Wed Jul 17, 2024 2:09 pm
by fearless_fool
Update: I realized that I had not run

Code: Select all

.\install.bat
.\export.bat
Those commands completed without error, but after doing so, I still get "No module named 'google'" as described in the original post.

Re: Cannot run esp_prov.py: No module named 'google'

Posted: Wed Jul 17, 2024 3:39 pm
by fearless_fool
Solved.

Although the https://github.com/espressif/esp-idf/tr ... pendencies states:

Code: Select all

This requires the following python libraries to run:
    bleak
    protobuf
    cryptography
To install the dependency packages needed, please run the following command:
    bash install.sh --enable-pytest
... calling `bash install.sh` does not work under Windows, and `.\install.bat` does not install the required modules. Instead, I found it was necessary to call `pip install` on the individual modules. In the ESP-IDF command window:

Code: Select all

PS C:\Espressif\frameworks\esp-idf-v5.2.2> pip install bleak
PS C:\Espressif\frameworks\esp-idf-v5.2.2> pip install protobuf
PS C:\Espressif\frameworks\esp-idf-v5.2.2> pip install cryptography
PS C:\Espressif\frameworks\esp-idf-v5.2.2> cd .\tools\esp_prov\
Now invoking `python esp_prov.py` works without error.