2016-03-11 143 views
0

(首先,對不起我的英文不好,我不是英文)。在py2exe中缺少模塊

昨天我完成了我的小程序。 今天我試着編譯但似乎是: prompt_image

這是安裝腳本:

from distutils.core import setup 
import py2exe 

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

我怎樣才能解決這個問題?

謝謝!

+0

這是一個gui程序嗎? – Busturdust

回答

1

嘗試明確地將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 

) 
0

請重新安裝py2exe;也許支持Python 3.5的其他版本