导入错误:找不到名为 allcontrols 的模块,使用 pywinauto 和 py2exe
我想从一个包含 pywinauto
模块的 Python 脚本生成一个 .exe
文件。
这个文件生成得很好,但是当我运行生成的 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
1 个回答
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",
]
}
}
)