我正在尝试为我的项目生成一个 exe。大约一个月前,当我的项目没有使用 ReportLab 时,它没有问题,但现在,没有那么多了。
搜索后,我发现问题是其中一个 pyinstaller 文件中缺少导入。问题解决了吗?不完全是。
现在我得到这个错误......
Traceback (most recent call last):
File "<string>", line 18, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\myproject\build\pyi.win32\myproject\out00-PYZ.pyz\reports.My_Report_File", line 10, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 431, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\myproject\build\pyi.win32\myproject\out00-PYZ.pyz\reportlab.pdfgen.canvas", line 25, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 431, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\myproject\build\pyi.win32\myproject\out00-PYZ.pyz\reportlab.pdfbase.pdfdoc", line 22, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 431, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\myproject\build\pyi.win32\myproject\out00-PYZ.pyz\reportlab.pdfbase.pdfmetrics", line 23, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 431, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\myproject\build\pyi.win32\myproject\out00-PYZ.pyz\reportlab.pdfbase._fontdata", line 158, in <module>
File "F:\Python\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 409, in importHook
raise ImportError("No module named %s" % fqname)
ImportError: No module named _fontdata_enc_winansi
环顾四周,我发现这仅导致了一个建议的解决方案,即强制在我的代码文件中进行所有导入。我有太多的报告文件,让我什至很难考虑这样做。
我读了一些关于隐藏进口的东西。也许这可以帮助我,但我不知道。任何帮助,将不胜感激。谢谢你。
编辑:py2exe 的类似问题和解决方案....