gpt4 book ai didi

python - 即使专门包含,cx-freeze 也无法包含模块

转载 作者:太空狗 更新时间:2023-10-30 01:39:08 24 4
gpt4 key购买 nike

我正在尝试使用 cx-freeze 创建我的应用程序的静态独立分发(The Spye Python Engine,www.spye.dk),但是,当我运行 cx-freeze 时,它​​显示:

Missing modules:
? _md5 imported from hashlib
? _scproxy imported from urllib
? _sha imported from hashlib
? _sha256 imported from hashlib
? _sha512 imported from hashlib
? _subprocess imported from subprocess
? configparser imported from apport.fileutils
? usercustomize imported from site

这是我的setup.py:

#!/usr/bin/env python
from cx_Freeze import setup, Executable

includes = ["hashlib", "urllib", "subprocess", "fileutils", "site"]
includes += ["BaseHTTPServer", "cgi", "cgitb", "fcntl", "getopt", "httplib", "inspect", "json", "math", "operator", "os", "os,", "psycopg2", "re", "smtplib", "socket", "SocketServer", "spye", "spye.config", "spye.config.file", "spye.config.merge", "spye.config.section", "spye.editor", "spye.framework", "spye.frontend", "spye.frontend.cgi", "spye.frontend.http", "spye.input", "spye.output", "spye.output.console", "spye.output.stdout", "spye.pluginsystem", "spye.presentation", "spye.util.html", "spye.util.rpc", "ssl", "stat,", "struct", "subprocess", "sys", "termios", "time", "traceback", "tty", "urllib2", "urlparse", "uuid"]

includefiles=[]
excludes = []
packages = []
target = Executable(
# what to build
script = "spye-exe",
initScript = None,
#base = 'Win32GUI',
targetDir = r"dist",
targetName = "spye.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)

setup(
version = "0.1",
description = "No Description",
author = "No Author",
name = "cx_Freeze Sample File",

options = {"build_exe": {"includes": includes,
"excludes": excludes,
"packages": packages
#"path": path
}
},

executables = [target]
)

请注意,我在包含列表中明确指定了缺少的模块。

我该如何解决这个问题?

最佳答案

缺少模块不一定是问题:许多模块尝试不同的导入以适应不同的平台或不同版本的 Python。例如,在 subprocess 中,您可以找到以下代码:

if mswindows:
...
import _subprocess

cx_Freeze 不知道这一点,所以它会尝试在 Linux/Mac 上查找 _subprocess,并将其报告为丢失。在 includes 中指定它们不会改变任何内容,因为它试图包含它们,但无法找到它们。

无论如何它都应该构建一个文件,因此请尝试运行它并查看它是否有效。

关于python - 即使专门包含,cx-freeze 也无法包含模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10205219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com