我想从包含.exe
模块的python脚本生成pywinauto
文件。
它构建正常,但是在运行生成的dist\pywinauto_sample.exe
时,我收到此错误:
Traceback (most recent call last):
File "pywinauto_sample.py", line 2, in <module>
from pywinauto import application
File "pywinauto\application.pyc", line 68, in <module>
File "pywinauto\controlactions.pyc", line 45, in <module>
File "pywinauto\tests\__init__.pyc", line 128, in <module>
File "pywinauto\tests\__init__.pyc", line 114, in __init_tests
ImportError: No module named allcontrols
这是我的pywinauto_sample.py
:
import pywinauto
from pywinauto import application
app = pywinauto.application.Application()
这是setup.py
:
from distutils.core import setup
import py2exe
setup(console=['pywinauto_sample.py'])
我用以下代码编译程序:
python setup.py py2exe
答案 0 :(得分:0)
将此添加到您的setup.py
:
from distutils.core import setup
import py2exe
setup(
console=
[
'pywinauto_sample.py'
],
options=
{
"py2exe":
{
"includes":
[
"pywinauto.tests.truncation",
"pywinauto.tests.translation",
"pywinauto.tests.repeatedhotkey",
"pywinauto.tests.overlapping",
"pywinauto.tests.missingextrastring",
"pywinauto.tests.missalignment",
"pywinauto.tests.miscvalues",
"pywinauto.tests.leadtrailspaces",
"pywinauto.tests.comparetoreffont",
"pywinauto.tests.comboboxdroppedheight",
"pywinauto.tests.asianhotkey",
"pywinauto.tests.allcontrols",
]
}
}
)