我看到了one question与此相关,但它并没有真正回答我的问题。
我编写了一个程序,旨在无需安装 python 即可使用;我使用 cx_freeze 来实现这一点。我写了一个setup.py,并在cmd中运行它。这一切都工作正常,尽管我确实收到了一些“缺少模块”警告,但它向我保证这可能不是问题:
Missing modules:
? _dummy_threading imported from dummy_threading
? ce imported from os
? doctest imported from heapq
? getopt imported from base64, quopri
? grp imported from shutil, tarfile
? org.python.core imported from copy
? os.path imported from os, py_compile, shutil
? posix imported from os
? pwd imported from posixpath, shutil, tarfile
? subprocess imported from os
This is not necessarily a problem - the modules may not be needed on this platform.
(我运行的是 Windows 8,从未抽出时间更新到 8.1)
导出后,我会看到两个文件; 'python34.dll' 和 “T-备份.exe”。当我运行 T-backup.exe 时,出现上述错误。
这是我的 setup.py,以防需要:
import sys
from cx_Freeze import setup, Executable
base = None
if (sys.platform == "win32"):
base = "Win32GUI"
exe = Executable(
script = "<path>\\T-Backup.py",
icon = "<path>\\Icon.ico",
targetName = "<path>\\exe\\T-Backup.exe",
base = base
)
includefiles = ["<path>\\Icon.ico","<path>\\backupfrom.tbk","<path>\\backupto.tbk"]
setup(
name = "T-Backup",
version = "0.1",
description = "Backs up Terraria Worlds and Players.",
author = "Sam Poirier (darthmorf)",
options = {'build_exe': {'include_files':includefiles}},
executables = [exe]
)
感谢您的帮助。
-达斯莫夫
最佳答案
我无法发表评论,所以我回答:
我认为您使用的是 64 位系统,并且您永远不会获得除“无”之外的基础。尝试改变
base = None
if (sys.platform == "win32"):
base = "Win32GUI"
至
base = "Win32GUI"
这解决了我的很多问题,与您所描述的类似......
如果您可以显示您实际导入的模块,那么我可能会有更多用处。
关于 python + cx_freeze 'cannot get zipimporter instance',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32723767/