This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrfutil dfu ble does not work on macOS

nrfutil dfu ble -ic NRF52 -pkg app_dfu_package-debug_1_1.0.2.zip
Traceback (most recent call last):
  File "/usr/local/bin/nrfutil", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/nordicsemi/__main__.py", line 1138, in ble
    ble_driver_init(conn_ic_id)
  File "/usr/local/lib/python3.8/site-packages/nordicsemi/__main__.py", line 67, in ble_driver_init
    from pc_ble_driver_py.ble_driver    import BLEDriver, Flasher
  File "/usr/local/lib/python3.8/site-packages/pc_ble_driver_py/ble_driver.py", line 77, in <module>
    import pc_ble_driver_py.lib.nrf_ble_driver_sd_api_v5 as driver
  File "/usr/local/lib/python3.8/site-packages/pc_ble_driver_py/lib/nrf_ble_driver_sd_api_v5.py", line 13, in <module>
    from . import _nrf_ble_driver_sd_api_v5
ImportError: dlopen(/usr/local/lib/python3.8/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.8/Python
  Referenced from: /usr/local/lib/python3.8/site-packages/pc_ble_driver_py/lib/_nrf_ble_driver_sd_api_v5.so
  Reason: image not found

nrfutil 6.1.0, macOS 10.15.7 (19H114). I've tried uninstalling and reinstalling. /Library/Frameworks/Python.framework does not exist.

Parents
  • Hi,

    I do not recall seeing this exact issue before, so my initial suggestions will be somewhat generic.

    Did you install nrfutil using pip? Typically you would install using pip install nrfutil. I suggest you use Python 3 (default python version on macOS is still Python 2).

    Do you use the Python that ships with MacOS or did you install a new Python distribution yourself? If you did (which is often a good idea), then I recommend using the pyenv approach as outlined here. This approach also makes a lot of sense if you will be using python more in the future (for instance if going to look into the nRF Connect SDK).

Reply
  • Hi,

    I do not recall seeing this exact issue before, so my initial suggestions will be somewhat generic.

    Did you install nrfutil using pip? Typically you would install using pip install nrfutil. I suggest you use Python 3 (default python version on macOS is still Python 2).

    Do you use the Python that ships with MacOS or did you install a new Python distribution yourself? If you did (which is often a good idea), then I recommend using the pyenv approach as outlined here. This approach also makes a lot of sense if you will be using python more in the future (for instance if going to look into the nRF Connect SDK).

Children
  • The path is hardcoded into the pc_ble_driver_py package.

    It appears that it requires python 3.8 to be installed from the python installer, rather than homebrew. I don't think pyenv will work.

    After installing via the installer, removing nrfutil and homebrew python, and then reinstalling nrfutil with the installed pip3, it works. It would be great if this worked with homebrew python or pyenv. At the very least it could check the location of python is correct when running this command, and if not provide instructions to the user.

Related