nRF54L15 protobuf error

Hello, I'm running an example of channel sounding using nRF54L15.

The build is fine, but the following error occurs during flash.

Python is using 3.12.4 version.
As you can see, we're using protobuf version 3.19.6 as well. (The same error occurred in 3.20.0 version)

But I keep getting protobuf errors, how do I fix it?

-------------------------------------------------------------------------

I solved this problem, but another problem occurred.

ModuleNotFoundError: No module named 'constants'

Parents
  • Hello,

    Sorry for the late reply. I was assigned your ticket, but was out of office yesterday. 

    I solved this problem, but another problem occurred.

    ModuleNotFoundError: No module named 'constants'

    Is there any way I can reproduce this issue? If so, can you please give some instructions on how to do it? If it is at all related to your initial issue, it seems like it is a toolchain issue. From the build log (probably from when you are flashing) it seems like it tries to use your default python installation, instead of the python version provided in the toolchain. Did you install a toolchain using VS Code? If so, which one do you use?

    Best regards,
    Edvin

  • Hello, thank you for your answer.

    Initially, I encountered a version-related error with protobuf, so I ran the following command:
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install protobuf==3.20.3
    After that, I started getting a 'constants' error.

    ModuleNotFoundError: No module named 'constants'

    I am using SDK v3.0.0, which I downloaded via nRF Connect for Desktop. and I'm using Python 3.12

    I'll be waiting for your reply.

    +

    I referred to the following post on Nordic DevZone:
    RE: nrfutil ModuleNotFoundError: No module named 'constants' 

    I did some research and found that issues occur with Python 3.10 and above because some outdated packages reference attributes like collections.Hashable, which no longer exist.
    Does this mean that SDK v3.0.0 cannot run on Python 3.12?

  • Are you trying to build a sample of ours? 

    kim_mj said:
    Does this mean that SDK v3.0.0 cannot run on Python 3.12?

    If so, are you using the toolchain that comes with NCS v3.0.0?

  • Yes, I have downloaded and currently using both the SDKs and Toolchains v3.0.0, and I am building and flashing the channel_sounding_ras_initiator example.

    The reason I mentioned the Python version is because I encountered an error (related to protobuf) during the build and flash process.

    ...
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

    To resolve the protobuf issue, I ran the following command:
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil

    After that, I started seeing consecutive errors related to constants and collections.

    ...
    ModuleNotFoundError: No module named 'constants'

    ...
    AttributeError: module 'collections' has no attribute 'Hashable'

    After searching online, I found that these types of errors could be related to the Python version, which led me to ask whether the Python version might be the cause of the problem.

    If I made any mistakes, could you please let me know?

    1) Even though I am using both the SDKs and Toolchain version 3.0.0, why am I getting these errors and unable to flash the program?

    (I'm not completely sure, but I think that when I run the flash, it uses the Python installed on my computer instead of the toolchain's Python.
    As you can see, the path follows C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe (my computer path), rather than the toolchain path like C:\ncs\toolchains\....)

    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\__main__.py", line 50, in <module>
        from nordicsemi.dfu.bl_dfu_sett import BLDFUSettings
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\bl_dfu_sett.py", line 52, in <module>
        from nordicsemi.dfu.package import Package
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\package.py", line 54, in <module>
        from nordicsemi.dfu.init_packet_pb import *
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\init_packet_pb.py", line 38, in <module>
        from . import dfu_cc_pb2 as pb
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\dfu_cc_pb2.py", line 32, in <module>
        _descriptor.EnumValueDescriptor(
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\google\protobuf\descriptor.py", line 920, in __new__
        _message.Message._CheckCalledFromGeneratedFile()
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
    
    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

    2)  Also, how can I resolve the issues that appear after fixing the protobuf version by running
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil?

    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\west.exe\__main__.py", line 7, in <module>
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 1085, in main
        app.run(argv or sys.argv[1:])
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 236, in run
        self.load_manifest()
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 254, in load_manifest
        self.manifest = Manifest.from_topdir(topdir=self.topdir,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1207, in from_topdir
        return Manifest(topdir=topdir, config=config,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1499, in __init__
        current_data=validate(self._ctx.current_data))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 541, in validate
        as_dict = _load(data)
                  ^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 207, in _load
        return yaml.safe_load(data)
               ^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 94, in safe_load
        return load(stream, SafeLoader)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 72, in load
        return loader.get_single_data()
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 37, in get_single_data
        return self.construct_document(node)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 46, in construct_document
        for dummy in generator:
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 398, in construct_yaml_map
        value = self.construct_mapping(node)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 204, in construct_mapping
        return super().construct_mapping(node, deep=deep)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 126, in construct_mapping
        if not isinstance(key, collections.Hashable):
                               ^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'collections' has no attribute 'Hashable'

    after C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install PyYAML=6.0.1 ,   

    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\__main__.py", line 53, in <module>
    from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 52, in <module>
    from nordicsemi.lister.device_lister import DeviceLister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\device_lister.py", line 39, in <module>
    from nordicsemi.lister.windows.lister_win32 import Win32Lister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\windows\lister_win32.py", line 43, in <module>
    from constants import DIGCF_PRESENT, DEVPKEY, DIGCF_DEVICEINTERFACE
    ModuleNotFoundError: No module named 'constants'

    final

    ...
    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    -- runners.nrfutil: Board with serial number 1057756188 flashed successfully.

Reply
  • Yes, I have downloaded and currently using both the SDKs and Toolchains v3.0.0, and I am building and flashing the channel_sounding_ras_initiator example.

    The reason I mentioned the Python version is because I encountered an error (related to protobuf) during the build and flash process.

    ...
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

    To resolve the protobuf issue, I ran the following command:
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil

    After that, I started seeing consecutive errors related to constants and collections.

    ...
    ModuleNotFoundError: No module named 'constants'

    ...
    AttributeError: module 'collections' has no attribute 'Hashable'

    After searching online, I found that these types of errors could be related to the Python version, which led me to ask whether the Python version might be the cause of the problem.

    If I made any mistakes, could you please let me know?

    1) Even though I am using both the SDKs and Toolchain version 3.0.0, why am I getting these errors and unable to flash the program?

    (I'm not completely sure, but I think that when I run the flash, it uses the Python installed on my computer instead of the toolchain's Python.
    As you can see, the path follows C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe (my computer path), rather than the toolchain path like C:\ncs\toolchains\....)

    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\__main__.py", line 50, in <module>
        from nordicsemi.dfu.bl_dfu_sett import BLDFUSettings
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\bl_dfu_sett.py", line 52, in <module>
        from nordicsemi.dfu.package import Package
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\package.py", line 54, in <module>
        from nordicsemi.dfu.init_packet_pb import *
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\init_packet_pb.py", line 38, in <module>
        from . import dfu_cc_pb2 as pb
      File "C:\Users\SJIT\AppData\Local\Programs\Python\Python312\Lib\site-packages\nordicsemi\dfu\dfu_cc_pb2.py", line 32, in <module>
        _descriptor.EnumValueDescriptor(
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\google\protobuf\descriptor.py", line 920, in __new__
        _message.Message._CheckCalledFromGeneratedFile()
    TypeError: Descriptors cannot be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
     1. Downgrade the protobuf package to 3.20.x or lower.
     2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
    
    More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

    2)  Also, how can I resolve the issues that appear after fixing the protobuf version by running
    C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install nrfutil?

    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\west.exe\__main__.py", line 7, in <module>
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 1085, in main
        app.run(argv or sys.argv[1:])
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 236, in run
        self.load_manifest()
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\app\main.py", line 254, in load_manifest
        self.manifest = Manifest.from_topdir(topdir=self.topdir,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1207, in from_topdir
        return Manifest(topdir=topdir, config=config,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 1499, in __init__
        current_data=validate(self._ctx.current_data))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 541, in validate
        as_dict = _load(data)
                  ^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\west\manifest.py", line 207, in _load
        return yaml.safe_load(data)
               ^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 94, in safe_load
        return load(stream, SafeLoader)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\__init__.py", line 72, in load
        return loader.get_single_data()
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 37, in get_single_data
        return self.construct_document(node)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 46, in construct_document
        for dummy in generator:
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 398, in construct_yaml_map
        value = self.construct_mapping(node)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 204, in construct_mapping
        return super().construct_mapping(node, deep=deep)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\yaml\constructor.py", line 126, in construct_mapping
        if not isinstance(key, collections.Hashable):
                               ^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'collections' has no attribute 'Hashable'

    after C:\ncs\toolchains\0b393f9e1b\opt\bin\python.exe -m pip install PyYAML=6.0.1 ,   

    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Traceback (most recent call last):
    File "<frozen runpy>", line 198, in _run_module_as_main
    File "<frozen runpy>", line 88, in _run_code
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Scripts\nrfutil.exe\__main__.py", line 4, in <module>
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\__main__.py", line 53, in <module>
    from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 52, in <module>
    from nordicsemi.lister.device_lister import DeviceLister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\device_lister.py", line 39, in <module>
    from nordicsemi.lister.windows.lister_win32 import Win32Lister
    File "C:\ncs\toolchains\0b393f9e1b\opt\bin\Lib\site-packages\nordicsemi\lister\windows\lister_win32.py", line 43, in <module>
    from constants import DIGCF_PRESENT, DEVPKEY, DIGCF_DEVICEINTERFACE
    ModuleNotFoundError: No module named 'constants'

    final

    ...
    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: C:\ncs\channel_sounding_ras_initiator\build\merged.hex
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    Usage: nrfutil [OPTIONS] COMMAND [ARGS]...
    Try 'nrfutil --help' for help.
    
    Error: no such option: --json
    -- runners.nrfutil: Board with serial number 1057756188 flashed successfully.

Children
No Data
Related