ImportError:没有使用pywinauto和py2exe命名为allcontrols的模块

时间:2014-08-06 16:30:19

标签: python py2exe pywinauto

我想从包含.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

1 个答案:

答案 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",
            ]
        }
    }
)

来源:http://permalink.gmane.org/gmane.comp.python.py2exe/4663