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

nrfutil ModuleNotFoundError: No module named 'constants'

Hi,

I have installed nrfutil on my Windows 10 computer and get the following error when running it:

C:\Users\00315055>nrfutil --help
Traceback (most recent call last):
File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python37\Scripts\nrfutil.exe\__main__.py", line 5, in <module>
File "c:\python37\lib\site-packages\nordicsemi\__main__.py", line 53, in <module>
from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial
File "c:\python37\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 52, in <module>
from nordicsemi.lister.device_lister import DeviceLister
File "c:\python37\lib\site-packages\nordicsemi\lister\device_lister.py", line 39, in <module>
from nordicsemi.lister.windows.lister_win32 import Win32Lister
File "c:\python37\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'

I have the following Python version:

C:\Users\00315055>python --version
Python 3.7.4

BR / Björn

  • An update:

    I installed the module called constants, but now I get another error:

    C:\Users\00315055>pip install constants
    Collecting constants
    Downloading files.pythonhosted.org/.../constants-0.6.0.tar.gz
    Building wheels for collected packages: constants
    Building wheel for constants (setup.py) ... done
    Stored in directory: C:\Users\00315055\AppData\Local\pip\Cache\wheels\75\a1\25\7e051dae7d8fb9db1c04b0fe309a8bea40111080d3b62f1ca9
    Successfully built constants
    Installing collected packages: constants
    Successfully installed constants-0.6.0
    You are using pip version 19.0.3, however version 20.2.3 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.

    C:\Users\00315055>nrfutil --help
    Traceback (most recent call last):
    File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
    File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "C:\Python37\Scripts\nrfutil.exe\__main__.py", line 5, in <module>
    File "c:\python37\lib\site-packages\nordicsemi\__main__.py", line 53, in <module>
    from nordicsemi.dfu.dfu_transport_serial import DfuTransportSerial
    File "c:\python37\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 52, in <module>
    from nordicsemi.lister.device_lister import DeviceLister
    File "c:\python37\lib\site-packages\nordicsemi\lister\device_lister.py", line 39, in <module>
    from nordicsemi.lister.windows.lister_win32 import Win32Lister
    File "c:\python37\lib\site-packages\nordicsemi\lister\windows\lister_win32.py", line 43, in <module>
    from constants import DIGCF_PRESENT, DEVPKEY, DIGCF_DEVICEINTERFACE
    ImportError: cannot import name 'DIGCF_PRESENT' from 'constants' (c:\python37\lib\site-packages\constants.py)

    So now it finds the module, but not the name 'DIGCF_PRESENT' in the module.

    Please advise!

  • Final update:

    1) I uninstalled components (it has nothing to do with nrfutil):

    pip uninstall components

    2) I uninstalled nrfutil:

    pip uninstall components

    3) I installed latest version of nrfutil:

    pip install nrfutil

    Now it works. Case closed!

    BR / Björn

  • Helllo Bjorn,

    i have the exact same issue as you had. But in my case your solution does not work. I cant get nrfutil to function properly.

    ImportError: cannot import name 'DIGCF_PRESENT' from 'constants' (c:\python37\lib\site-packages\constants.py)

    This error does still appear.

    Please help.

    Python 3.9.0

  • Fixed by downgrading to Python 3.8.6 and pip 20.1.1

  • Hi A Wagner,

    Today I installed Python and nrfutil on a new computer. I installed Python 3.9.1 and then nrfutil through pip. I had the same issue as originally reported here, so it seems nrfutil does not work with Python 3.9.x. I downgraded Python to 3.7 and then nrfutil worked again.

    Nordic should fix this issue, very irritating when you download something from scratch that crashes first thing :-(

    BR / Björn

Related