Q:
I bundled a small script written in python using py2exe. The script uses many packages and one of them is reportlab. After bundling using py2exe I tried to run the executable file and it is returning following error:
C:\Python26\dist>DELchek.exe
Traceback(most recent call last):
File"DELchek.py", line 12,in<module>
File"reportlab\pdfgen\canvas.pyc", line 25,in<
File"reportlab\pdfbase\pdfdoc.pyc", line 22,in
File"reportlab\pdfbase\pdfmetrics.pyc", line 23,
File"reportlab\pdfbase\_fontdata.pyc", line 158,
ImportError:Nomodule named _fontdata_enc_winansi
But I could see the '_fontdata_enc_winansi' module in reportlab folder. Could someone help me to fix this.
A:
|
I've had the same problem in the past bundling reportlab with py2exe. It imports of a bunch of modules dynamically, which py2exe does not recognize when assembling the dependencies. The brute-force fix is to import the required modules directly in your code: from reportlab.pdfbase import _fontdata_enc_winansi
A search also shows that Sankar found another solution, which is including the following packages in the setup script: packages=[
|