python使用pyinstaller生成可执行文件提示错误

这个是错误代码

C:\Users\Dell\Desktop\PyInstaller-2.1>computer\dist\computer.exe
desktop img saved ok!!!!
Traceback (most recent call last):
  File "<string>", line 84, in <module>
  File "<string>", line 22, in get_webcamimg
  File "C:\Users\Dell\Desktop\PyInstaller-2.1\computer\build\computer\out00-PYZ.
pyz\VideoCapture", line 50, in __init__
  File "C:\Users\Dell\Desktop\PyInstaller-2.1\computer\build\computer\out00-PYZ.
pyz\PIL.ImageFont", line 262, in load_path
IOError: cannot find font file

修改python目录中的ImageFont.py中的load_path函数为下面的就可以解决

def load_path(filename):
    for dir in sys.path:
        if isDirectory(dir):
            try:
                #return load(os.path.join(dir, filename))
                return load_default()
            except IOError:
                pass
            raise IOError("cannot find font file")

python使用pyinstaller生成可执行文件提示错误》上有3条评论

  1. hello——Python

    你好,你说的“修改python目录中的ImageFont.py中的load_path函数为下面的就可以解决”中指的是哪个python目录

    回复
  2. hello——Python

    D:Pythonpython_toolPyInstaller-2.1>python pyinstaller.py -F capture.py161 INFO: wrote D:Pythonpython_toolPyInstaller-2.1capturecapture.spec188 INFO: Testing for ability to set icons, version resources…269 INFO: … resource update available273 INFO: UPX is not available.312 INFO: Processing hook hook-os525 INFO: Processing hook hook-time536 INFO: Processing hook hook-cPickle667 INFO: Processing hook hook-_sre927 INFO: Processing hook hook-cStringIO1049 INFO: Processing hook hook-encodings1068 INFO: Processing hook hook-codecs2516 INFO: Extending PYTHONPATH with D:Pythonpython_toolPyInstaller-2.12517 INFO: checking Analysis2519 INFO: building because capture.py changed2519 INFO: running Analysis out00-Analysis.toc2520 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable17530 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none …17532 INFO: Found manifest C:WindowsWinSxSManifestsx86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest17561 INFO: Searching for file msvcr90.dll17561 INFO: Found file C:WindowsWinSxSx86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91msvcr90.dll17562 INFO: Searching for file msvcp90.dll17562 INFO: Found file C:WindowsWinSxSx86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91msvcp90.dll17562 INFO: Searching for file msvcm90.dll17563 INFO: Found file C:WindowsWinSxSx86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91msvcm90.dll17711 INFO: Analyzing D:Pythonpython_toolPyInstaller-2.1PyInstallerloader_pyi_bootstrap.py17737 INFO: Processing hook hook-os17765 INFO: Processing hook hook-site17792 INFO: Processing hook hook-encodings17907 INFO: Processing hook hook-time17911 INFO: Processing hook hook-cPickle17980 INFO: Processing hook hook-_sre18105 INFO: Processing hook hook-cStringIO18209 INFO: Processing hook hook-codecs18671 INFO: Processing hook hook-pydoc18992 INFO: Processing hook hook-email19098 INFO: Processing hook hook-httplib19134 INFO: Processing hook hook-email.message19223 INFO: Analyzing D:Pythonpython_toolPyInstaller-2.1PyInstallerloaderpyi_importers.py19289 INFO: Analyzing D:Pythonpython_toolPyInstaller-2.1PyInstallerloaderpyi_archive.py19331 INFO: Analyzing D:Pythonpython_toolPyInstaller-2.1PyInstallerloaderpyi_carchive.py19372 INFO: Analyzing D:Pythonpython_toolPyInstaller-2.1PyInstallerloaderpyi_os_path.py19381 INFO: Analyzing capture.py19437 INFO: Processing hook hook-PIL19529 INFO: Processing hook hook-PIL.Image20563 INFO: Processing hook hook-distutils20815 INFO: Hidden import ‘codecs’ has been found otherwise20816 INFO: Hidden import ‘encodings’ has been found otherwise20818 INFO: Looking for run-time hooks20819 INFO: Analyzing rthook D:Pythonpython_toolPyInstaller-2.1PyInstallerloaderrthookspyi_rth_PIL_Image.py21158 INFO: Adding Microsoft.VC90.DebugCRT to dependent assemblies of final executable21230 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none …21232 WARNING: Assembly not found21233 ERROR: Assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found21303 INFO: Using Python library C:Windowssystem32python27.dll21394 INFO: Warnings written to D:Pythonpython_toolPyInstaller-2.1capturebuildcapturewarncapture.txt21398 INFO: checking PYZ21403 INFO: building because name changed21404 INFO: building PYZ (ZlibArchive) out00-PYZ.toc22308 INFO: checking PKG22325 INFO: building because name changed22326 INFO: building PKG (CArchive) out00-PKG.pkg24121 INFO: checking EXE24154 INFO: building because name changed24155 INFO: building EXE from out00-EXE.toc24210 INFO: Appending archive to EXE D:Pythonpython_toolPyInstaller-2.1capturedistcapture.exeD:Pythonpython_toolPyInstaller-2.1>D:Pythonpython_toolPyInstaller-2.1>D:Pythonpython_toolPyInstaller-2.1>D:Pythonpython_toolPyInstaller-2.1>cd captureD:Pythonpython_toolPyInstaller-2.1capture>dir 驱动器 D 中的卷是 安装盘 卷的序列号是 7414-234B D:Pythonpython_toolPyInstaller-2.1capture 的目录2014/05/07 21:46 .2014/05/07 21:46 ..2014/05/08 09:16 474 capture.spec2014/05/07 21:46 build2014/05/07 21:46 dist 1 个文件 474 字节 4 个目录 55,227,154,432 可用字节D:Pythonpython_toolPyInstaller-2.1capture>cd distD:Pythonpython_toolPyInstaller-2.1capturedist>dir 驱动器 D 中的卷是 安装盘 卷的序列号是 7414-234B D:Pythonpython_toolPyInstaller-2.1capturedist 的目录2014/05/07 21:46 .2014/05/07 21:46 ..2014/05/08 09:16 4,415,005 capture.exe 1 个文件 4,415,005 字节 2 个目录 55,227,154,432 可用字节D:Pythonpython_toolPyInstaller-2.1capturedist>capture.exe05-08-09-16-50destop img save okTraceback (most recent call last): File “”, line 100, in File “”, line 32, in get_webcamimg File “D:Pythonpython_toolPyInstaller-2.1capturebuildcaptureout00-PYZ.pyzVideoCapture”, line 50, in __init__ File “D:Pythonpython_toolPyInstaller-2.1capturebuildcaptureout00-PYZ.pyzPIL.ImageFont”, line 247, in load_pathIOError: cannot find font fileD:Pythonpython_toolPyInstaller-2.1capturedist>我的错误跟你一样的,请问怎么解决,你说的Python目录是安装目录还是其他目录,安装目录里没有你说的ImageFont.py

    回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注