2017-02-16 54 views
0

使用py2exe我创建了我的脚本的exe版本,我找到了指令here。该脚本编译良好,每个生成一个dist和build文件夹,但是当我在命令行上运行该程序时,会出现此错误。 N.B脚本在我的IDE环境下工作正常,但是我打算给同事一个exe版本。我该如何解决这个错误?python exe文件导入错误

Traceback (most recent call last): 
    File "tester2.py", line 4, in <module> 
ImportError: No module named mechanize 

这里是setup.py文件:

from distutils.core import setup 
import py2exe 

setup(

    console = ['tester2.py'], 
    zipfile = None, 
) 

回答

0

您必须声明你的依赖。 这是我的设置

setup(
    executables=executables, 
    options=options, 
    name='bla', 
    version='0.3', 
    packages=[...], 
    url='', 
    license='', 
    author='', 
    author_email='', 
    description='', requires=['pandas', 'unidecode', 'click', 
           'xlsxwriter'] // you would have to add mechanize here 
) 
+0

我仍然得到同样的错误 – Nobi