python exe文件上的ImportError

时间:2017-02-16 09:28:22

标签: python

使用py2exe我使用我发现here的说明创建了我脚本的exe版本。脚本编译得很好并且每个都生成一个dist和build文件夹但是当我在命令行上运行程序时它会出现这个错误。 N.B脚本在我的IDE环境中工作正常,但我打算给同事一个exe版本。如何解决这个错误?

to-report modify-links-in-list [ input_list_of_links ]  

  ;;; input must be a list of links, not an agentset
    foreach input_list_of_links [
    [x] -> 
    ask x [
      set example_var example_var + 1
    ]
  ]

  report input_list_of_links  
end

这是setup.py文件:

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

2 个答案:

答案 0 :(得分: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
)

答案 1 :(得分:0)

您是否已将文件添加到构建中?

请查看WHERE (tblfile_leave.EMP_NAME = @username AND tblfile_leave.YEAR = @year) 中的include选项:exe built with cx_Freeze, PyQt5, Python3 can't import ExtensionLoader_PyQt5_QtWidgets.py and run

此外,这是我对类似问题的解决方案,如何添加文件以构建并在以后运行它们:Python - create an EXE that runs code as written, not as it was when compiled