py2exe中缺少模块(Missing modules in py2exe)

编程入门 行业动态 更新时间:2024-10-22 18:44:40
py2exe中缺少模块(Missing modules in py2exe) python

(首先,抱歉我的英语不好,我不是英语)。

昨天我完成了我的小程序。 今天我已经尝试编译,但看起来: prompt_image

这是安装脚本:

from distutils.core import setup import py2exe setup(console=['my_program.py'])

我怎么解决这个问题?

谢谢!

(First of all, sorry for my bad english, I'm not english).

Yesterday I've finished my little program. Today I've tried to compile that but appear that: prompt_image

This is the setup script:

from distutils.core import setup import py2exe setup(console=['my_program.py'])

How can I solve this problem?

Thank you!

最满意答案

尝试将py2exe选项明确传递给您的设置。

我通常按​​照这个常规setup.py来进行py2exe程序。

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 )

Try explicitly passing a py2exe option to your setup.

I usually follow this general setup.py for a py2exe program.

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 )

更多推荐

本文发布于:2023-08-06 19:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1453838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   py2exe   modules   Missing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!