带有 nidaqmx 的 Pyinstaller

发布于 2025-01-09 04:25:14 字数 762 浏览 6 评论 0原文

我有一个用 python 编写的软件,我试图将其打包成可执行文件。其中一个模块有问题,我找不到任何相关信息:nidaqmx

运行标准 pyinstaller 后,例如。

pyinstaller myprogram.py

构建成功完成,但在警告文件中指出缺少 nidaqmx。然后,在运行可执行文件时,我得到以下信息:

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

我还注意到站点包中的 nidaqmx 文件夹尚未复制。我尝试过的事情:

  • 添加“nidaqmx”作为隐藏导入(来自 .spec 文件或命令行)。添加与项目无关的其他模块似乎可以工作文件(意味着文件夹被复制)。
  • 将钩子路径添加到 .spec 文件

不确定从这里去哪里。感谢您的任何建议。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

写下不归期 2025-01-16 04:25:14

我解决了 nidaqmx/__init__.py 中的几行注释,并设法使可执行文件正确运行

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']

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']

孤城病女 2025-01-16 04:25:14

如果您不想编辑 nidaqmx 的源代码,您可以将 --copy-metadata 参数添加到 PyInstaller 命令中,如下所示:

pyinstaller --copy-metadata nidaqmx

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文