Skip to main content
 首页 » 编程设计

python之使用 Snap7 为 PLC 制作可执行的 python 程序

2025年04月02日8softidea

我一直在尝试使用 Snap7 在 Python 中编写程序,但现在我想让它成为它的可执行文件。我使用 py2exe 制作 *.exe 文件并在未安装 python 的 Windows 上运行它。但是,每次我尝试打开应用程序时,cmd 窗口都会显示此错误。

Traceback (most recent call last): 
  File "Sniffer.py", line 22, in <module> 
  File "snap7\client.pyc", line 34, in __init__ 
  File "snap7\common.pyc", line 54, in load_library 
  File "snap7\common.pyc", line 47, in __init__ 
  File "ctypes\__init__.pyc", line 440, in LoadLibrary 
  File "ctypes\__init__.pyc", line 362, in __init__ 
WindowsError: [Error 193] %1 is not a valid Win32 application 

我该怎么办?

请您参考如下方法:

SNAP7 库附带的 *.dll 文件存在问题。我用它的 32 位版本替换了这些文件,现在它可以工作了。