Troubles with python .exe file and snap7

225 Views Asked by At

OS: Windows 10 python: 3.11.3 snap7: vb6

i was triying to make a exe file with my python code,this code only take plc data base info and shows in a gui, the python code works fine, but when i run the exe file it shows the next message:

(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!)`

i try adding the snap7.dll file to the system 32 folder, then added to the system PATH, in pyinstaller i already used (--add-binary "C:\Windows\System32\snap7.dll;.") to add the file and the problem still there, i tried with auto py to exe too but didnt works.

help me please!!!!

1

There are 1 best solutions below

1
On

i solve it, the problem was the version of snap7, i change it for the 1.4.2 and now works