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

when starting nrfutil.exe after build from source: import error (due to invalid module)

Hello

I simply wanted to build an executable from a customized nrfutil. Ran the "pyinstaller nrfutil.spec" and afterwards started the nrfutil.exe from command line. This reported the import error "no module named package". After ensuring that the module exists, and after adding the path explicitly to the pathex variable in the .spec file, ths error remained. Having a look into the "warn-nrfutil.txt" i noticed that the module warning was written as "invalid module named package" and not "missing module named package". It seems that pyinstaller had found the module but classified it as invalid.

As a next step, I wanted to see if the error can be reproduced on another pc with a new and clean installation of the python environment and an untouched download of the latest nrfutil release's source from GitHub. The result was similar but not exactly the same.

Version of python: 2.7.16 (installed using the miniconda 2 installer)

Source for nrfutil: v6.0 (release from GitHub)

Step 1: Build Exe with "pyinstaller nrfutil.spec"

Step 2: Run Exe in subdirectory "dist"

---> Command Shell: ImportError: No module named crc16

---> warn-nrfutil.txt: invalid module named nordlicsemi.dfu.crc16

What is the reason for that?

Parents
  • Already back..

    The problem seems to be solved now. I was not aware of that the mentioned modules (package and crc16 and further) need to be compiled in a first step.

    The infocenter on page https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrfutil%2FUG%2Fnrfutil%2Fnrfutil_install_from_source.html says that you have three options for setting up nrfutil:

    a) Run nRF Util from the sources without installation

    b) Install the library to the local Python site-packages and script folder

    c) Generate a self-contained executable version of the utility

    Is it correct, that for option c) it is required to do step b) firstly? If yes, I think this should be clarified in the documentation. Then it is not an "either or" between the three options. Thank you.

  • Thanks for the update. I don't think you should have to complete option b) in order to make the executable. But you need to install the dependencies in requirements.txt. Also, didn't you get any build errors? nrfutil v.6.0.0 requires Python 3.6 or above while you're using 2.7.16.    

Reply
  • Thanks for the update. I don't think you should have to complete option b) in order to make the executable. But you need to install the dependencies in requirements.txt. Also, didn't you get any build errors? nrfutil v.6.0.0 requires Python 3.6 or above while you're using 2.7.16.    

Children
  • Hi Vidar

    I did some tries and have to confirm: option b) is NOT required for c). I mixed up things because while I was executing b) I was fixing some bugs in my source which actually were the reason for the module to be classified as "invalid" (and not the fact that I omitted b). And then, to make it more confusing: A conda environment with pytion v3.7.2 was enabled at the time when I made it working, not being aware of it. Sorry for the wrong conclusions.

  • No worries. Thanks again for the update. I'm glad to hear that you figured it out.