【问题标题】:Missing modules in py2exepy2exe 中缺少模块
【发布时间】:2016-03-11 19:46:22
【问题描述】:

(首先,对不起我的英语不好,我不是英语)。

昨天我完成了我的小程序。 今天我试图编译它,但似乎: prompt_image

这是安装脚本:

from distutils.core import setup
import py2exe

setup(console=['my_program.py'])

我该如何解决这个问题?

谢谢!

【问题讨论】:

  • 这是一个 gui 程序吗?

标签: python module py2exe


【解决方案1】:

尝试将py2exe 选项显式传递给您的设置。

对于 py2exe 程序,我通常遵循这个通用 setup.py。

from distutils.core import setup
import os
import shutil
import py2exe



data_files = []
setup(
    name='ApplicationName',
    console=['script_file.py'], # 'windows' means it's a GUI, 'console' It's a console program, 'service' a Windows' service, 'com_server' is for a COM server
    # You can add more and py2exe will compile them separately.
    options={ # This is the list of options each module has, for example py2exe, but for example, PyQt or django could also contain specific options
        'py2exe': {
            'packages': [],
            'dist_dir': 'dist', # The output folder
            'compressed': True, # If you want the program to be compressed to be as small as possible
            'includes': ['os', 'logging', 'yaml', 'sqlalchemy', 'pymysql'], # All the modules you need to be included, I added packages such as PySide and psutil but also custom ones like modules and utils inside it because py2exe guesses which modules are being used by the file we want to compile, but not the imports, so if you import something inside main.py which also imports something, it might break.
        }
    },

    data_files=data_files # Finally, pass the

)

【讨论】:

    【解决方案2】:

    请重新安装py2exe;可能是支持 Python 3.5 的不同版本

    【讨论】:

      猜你喜欢
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多