python .exe 文件和 snap7 出现问题

问题描述 投票:0回答:2

OS: Windows 10 python: 3.11.3 snap7: vb6

我试图用我的python代码制作一个exe文件,该代码仅获取plc数据库信息并在gui中显示,python代码工作正常,但是当我运行exe文件时,它显示下一条消息:

    (C:\Users\Horus\OneDrive\Escritorio\Proyectos\HA-047\Python\Python\dist>main.exe Traceback (most recent call last): File "PyInstaller\loader\pyimod03_ctypes.py", line 77, in __init__ File "ctypes\__init__.py", line 376, in __init__ OSError: [WinError 193] %1 no es una aplicación Win32 válida

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
 File "main.py", line 43, in <module>
 File "snap7\client\__init__.py", line 64, in __init__
 File "snap7\common.py", line 72, in load_library
 File "snap7\common.py", line 64, in __init__
 File "ctypes\__init__.py", line 454, in LoadLibrary
 File "PyInstaller\loader\pyimod03_ctypes.py", line 79, in __init__
 pyimod03_ctypes.install.<locals>.PyInstallerImportError: Failed to load dynlib/dll                                    `C:\\Users\\Horus\\AppData\\Local\\Temp\\_MEI194202\\snap7.dll.                                                Most likely this dynlib/dll was notfound when the application was frozen.`
[17212] Failed to execute script 'main' due to unhandled exception!)`

我尝试将 snap7.dll 文件添加到系统 32 文件夹,然后添加到系统 PATH,在 pyinstaller 中我已经使用了 (--add-binary "C:\Windows\System32\snap7.dll;.") 添加文件和问题仍然存在,我也尝试使用 auto py to exe 但不起作用。

请帮助我!!!!

python pyinstaller exe plc snap7
2个回答
1
投票

我解决了,问题是snap7的版本,我把它改成1.4.2,现在可以了


0
投票

您好,我遇到了同样的问题,https://github.com/rokm帮助我使用 pyinstaller --collect-binaries snap7 main.py

© www.soinside.com 2019 - 2024. All rights reserved.