1

I have a piece of software written in python that I am trying to package into an executable. One of the modules is being problematic and I can't find any information on it: nidaqmx

After running standard pyinstaller, eg.

pyinstaller myprogram.py

The build completes successfully but in the warnings file it notes that nidaqmx is missing. Then when running the executable, I get the following:

File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "nidaqmx\__init__.py", line 11, in <module>
  File "importlib\metadata.py", line 530, in version
  File "importlib\metadata.py", line 503, in distribution
  File "importlib\metadata.py", line 177, in from_name
  importlib.metadata.PackageNotFoundError: nidaqmx

I also notice that the nidaqmx folder from the site-packages has not been copied. Things I have tried:

  • add 'nidaqmx' as hidden import (both from .spec file or command line). Adding other modules unrelated to the project seems to work file (meaning the folder is copied over).
  • add a hookpath to the .spec file

Not sure where to go from here. Thanks for any advice.

Cusco88
  • 11
  • 1

2 Answers2

1

I resolved this commenting few lines in the nidaqmx/__init__.py and managed to have the executable running correctly

from nidaqmx.errors import DaqError, DaqWarning, DaqResourceWarning
from nidaqmx.scale import Scale
from nidaqmx.task import Task
from nidaqmx._task_modules.read_functions import CtrFreq, CtrTick, CtrTime

# try:
#     from importlib.metadata import version
# except ImportError:
#     from importlib_metadata import version

# __version__ = version(__name__)

__all__ = ['errors', 'scale', 'stream_readers', 'stream_writers', 'task']

0

If you don't want to edit the source code of nidaqmx you can add the --copy-metadata argument to the PyInstaller command like this:

pyinstaller --copy-metadata nidaqmx
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83