【问题标题】:Build an executable with only the libraries wanted?仅使用所需的库构建可执行文件?
【发布时间】:2019-08-02 15:37:05
【问题描述】:

我正在使用cx_freeze 来构建独立的可执行文件。以下是此类setup.py 文件的示例。

import os
import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'
exe = [Executable("main.py")]
os.environ['TCL_LIBRARY'] = r'C:\\Users\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\\Users\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tk8.6'
options = {
  'build_exe': {
    'includes': ['scipy.io', 'scipy.spatial.ckdtree'],
    'include_files': [r'C:\\Users\\dmurugesan\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tcl86t.dll',
                      r'C:\\Users\\dmurugesan\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tk86t.dll',
                      r'C:\\Users\\dmurugesan\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\'
                      r'pyqt5_tools\\platforms\\qwindows.dll'],
    'packages': ['pkg_resources._vendor', 'numpy', 'scipy', 'pydub', 'soundfile', 'cffi'],
  }
}

setup(name="lTBA", version="0.4", description='To be added',
  options=options, executables=exe)

尽管在提到要包含的库列表之后,构建包含了环境中存在的所有库!我该如何克服这个问题?

【问题讨论】:

    标签: python executable cx-freeze


    【解决方案1】:

    您可以定义要排除的库:

    'build_exe': {
        'excludes': ['library1_name', 'library2_name'], 
        # ...
    }
    

    【讨论】:

      猜你喜欢
      • 2019-01-17
      • 1970-01-01
      • 2017-08-21
      • 1970-01-01
      • 2013-08-20
      • 2010-11-11
      • 1970-01-01
      • 1970-01-01
      • 2021-07-17
      相关资源
      最近更新 更多