从另一台计算机运行冻结程序时出现cxFreeze错误

2024-05-03 04:25:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python编写了一个脚本,使用win32print模块在Windows上打印某些内容。我用下面的setup.py冻结了它:

import sys
from cx_Freeze import setup, Executable


base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"include_msvcr":True,'includes':['win32print','win32ui']}

setup(name='scoate',
      version='0.1',
      options={"build_exe": build_exe_options},
      description='scoate la printer',
      executables=[Executable('sand2.py', base=base)]
      )

我在Windows7上运行了exe,运行良好。当我把程序复制到我爸爸的Windows XP上时,它会弹出错误:

^{pr2}$

以下是生成的文件:

library.zip
mfc100u.dll
msvcp100.dll
MSVCR100.dll
PIL._imaging.pyd
PIL._imagingft.pyd
python34.dll
sand2.exe
unicodedata.pyd
win32print.pyd
win32ui.pyd
_bz2.pyd
_hashlib.pyd
_lzma.pyd

plot.py中的第1行是"import win32print"。但是正如您所看到的,它存在于生成的文件中。怎么了?在

PS如果我把'includes':[...]setup.py中删除,那是一样的。我尝试用pyinstaller冻结它,它在另一台机器上运行正常,但是pyinstaller不支持python3。在


Tags: pyimportbuildbasewindowssyssetupexe