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 execut
Skip graphics if you are not using them...
packages= [
'reportlab',
'reportlab.lib',
'reportlab.pdfbase',
'reportlab.pdfgen',
'reportlab.platypus',
]
setup(name='pitman',
version='1.0',
author='cue',
data_files = dataFiles,
console=['xxx.py', 'yyy.py'], # change to windows=[...]
options = {
"py2exe": { "dll_excludes": ["MSVCP90.dll"],
"packages": packages,
"includes": includes }
}
)
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
from reportlab.pdfbase import _fontdata_enc_macroman
from reportlab.pdfbase import _fontdata_enc_standard
from reportlab.pdfbase import _fontdata_enc_symbol
from reportlab.pdfbase import _fontdata_enc_zapfdingbats
from reportlab.pdfbase import _fontdata_enc_pdfdoc
from reportlab.pdfbase import _fontdata_enc_macexpert
from reportlab.pdfbase import _fontdata_widths_courier
from reportlab.pdfbase import _fontdata_widths_courierbold
from reportlab.pdfbase import _fontdata_widths_courieroblique
from reportlab.pdfbase import _fontdata_widths_courierboldoblique
from reportlab.pdfbase import _fontdata_widths_helvetica
from reportlab.pdfbase import _fontdata_widths_helveticabold
from reportlab.pdfbase import _fontdata_widths_helveticaoblique
from reportlab.pdfbase import _fontdata_widths_helveticaboldoblique
from reportlab.pdfbase import _fontdata_widths_timesroman
from reportlab.pdfbase import _fontdata_widths_timesbold
from reportlab.pdfbase import _fontdata_widths_timesitalic
from reportlab.pdfbase import _fontdata_widths_timesbolditalic
from reportlab.pdfbase import _fontdata_widths_symbol
from reportlab.pdfbase import _fontdata_widths_zapfdingbats
A search also shows that Sankar found another solution, which is including the following packages in the setup script:
packages=[
'reportlab',
'reportlab.graphics.charts',
'reportlab.graphics.samples',
'reportlab.graphics.widgets',
'reportlab.graphics.barcode',
'reportlab.graphics',
'reportlab.lib',
'reportlab.pdfbase',
'reportlab.pdfgen',
'reportlab.platypus',
],