Issue
I'm trying to generate an exe for my project. It worked without problems about a month back when my project didn't use ReportLab, but now, not so much.
After searching through, I found that the problem was a missing import in one of the pyinstaller files. Problem Solved right? Not exactly.
Now I get this error...
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
Searching around, I found this leading to only one proposed solution which was to force all the imports in my code files. I have way too many report files making it difficult for me to even think about doing that.
I read something about hidden imports. Maybe that may help me out, but I don't know. Any help would be appreciated. Thank you.
Edit: A similar problem and solution for py2exe....
Solution
I don't know if I this is the proper way to do it... but I'm starting to pull my hair out.
After reading around and wasting a bunch of time, ...
I found a post by someone which suggests copying the whole missing library folder (in my case it was in site-packages of my pythonxx) into the folder containing the exe. Walla! It worked.
If there is a better/proper way to do this, please enlighten me.
Answered By - Ryan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.