我在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)]
)
我在Windows 7上运行了exe,运行正常。当我将程序复制到我父亲的Windows XP时,它会发出错误:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
File "sand2.py", line 4, in <module>
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\Users\Ghena\Desktop\tata\plot.py", line 1, in <module>
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 539, in _check_name_wrapper
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1692, in load_module
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
以下是生成的文件:
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
。