【发布时间】:2015-02-13 15:55:06
【问题描述】:
我正在尝试使用 p2exe 从一个使用 pymodbus 和 twisted 的 python 脚本构建一个 exe(显然有很多底层依赖项)。我可以构建 exe,但它无法正常运行。我试图弄清楚我在设置环境时做错了什么。我确信这不是我的脚本,因为我可以从 python 命令行解释器很好地运行它。
我的 python 脚本使用这些模块...
from pymodbus.server.async import StartTcpServer
from pymodbus.datastore import ModbusSequentialDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
import sys
import logging
from twisted.internet.task import LoopingCall
我在 python setup1.py py2exe 上收到此错误...
The following modules appear to be missing
['Crypto.PublicKey._fastmath', 'FCNTL', 'OpenSSL', 'OpenSSL.SSL', 'OpenSSL._util', 'PAM', 'System', 'System.IO.Ports', 'TERMIOS', '_scproxy',
'gmpy', 'idna', 'pkg_resources', 'pyasn1.codec.ber', 'pyasn1.error', 'pyasn1.type', 'queue', 'resource', 'service_identity', 'service_identity
.pyopenssl', 'twisted.python._initgroups', 'twisted.python.sendmsg']
它构建 exe。当我运行 exe 时,会发生这种情况......
C:\Users\jlaird\Desktop\slush\dbclienttest\dist>modbus_slave2.exe
Traceback (most recent call last):
File "modbus_slave2.py", line 1, in <module>
File "pymodbus\server\async.pyc", line 18, in <module>
File "pymodbus\internal\ptwisted.pyc", line 5, in <module>
File "twisted\conch\manhole_ssh.pyc", line 14, in <module>
File "twisted\conch\ssh\factory.pyc", line 15, in <module>
File "twisted\conch\ssh\transport.pyc", line 32, in <module>
File "twisted\conch\ssh\keys.pyc", line 20, in <module>
ImportError: No module named pyasn1.error
如果我启动 python 并执行“import pyasn1”,它会毫无错误地导入。我也可以很好地导入 twisted 和 pymodbus。 Python 可以访问它,但 py2exe 不能。为什么?
【问题讨论】:
标签: python python-2.7 py2exe