py2exe没有找到已安装的模块?

时间:2015-02-13 15:55:06

标签: python python-2.7 py2exe

我试图使用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并执行导入pyasn1&#39;它导入没有错误。我也可以很好地导入twisted和pymodbus。 Python可以访问它但不能访问py2exe。为什么?

1 个答案:

答案 0 :(得分:0)

想出来...由于某种原因,pyasn1的build \ lib文件夹的内容没有复制到C:\ Python27 \ Lib \ site-packages中。只复制了一个鸡蛋。所以我将文件夹移到了site-packages中,py2exe构建了一个可行的可执行文件。

相关问题