我目前正在与reportlab一起在机器学习过程之后创建自动报告。好吧,它的确在Windows上创建了一个完美的报告。但是,当我尝试将工作放到远程服务器上时,一切都可以完美运行,直到出现“ doc.build(Story)”问题
File "train_prediction.py", line 551, in create_pdfdoc pdf_doc.build(story)
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/doctemplate.py", line 1038, in build self.handle_flowable(flowables)
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/doctemplate.py", line 892, in handle_flowable if frame.add(f, canv, trySplit=self.allowSplitting):
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/frames.py", line 167, in _add w, h = flowable.wrap(aW, h)
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/flowables.py", line 495, in wrap return self.drawWidth, self.drawHeight
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/flowables.py", line 489, in getattr self._setup_inner()
File "/home/adservio/periosystem/perio-env/lib64/python3.6/site-packages/reportlab/platypus/flowables.py", line 457, in _setup_inner self.drawWidth = width or self.imageWidth ValueError: The truth va
lue of an array with more than one element is ambiguous. Use a.any() or a.all()
def create_pdfdoc(pdfdoc, story):
"""
Creates PDF doc from story.
"""
pdf_doc = BaseDocTemplate(pdfdoc, pagesize = PAGE_SIZE,
leftMargin = MARGIN_SIZE, rightMargin = MARGIN_SIZE,
topMargin = MARGIN_SIZE, bottomMargin = MARGIN_SIZE)
main_frame = Frame(MARGIN_SIZE, MARGIN_SIZE,
PAGE_SIZE[0] - 2 * MARGIN_SIZE, PAGE_SIZE[1] - 2 * MARGIN_SIZE,
leftPadding = 0, rightPadding = 0, bottomPadding = 0,
topPadding = 0, id = 'main_frame')
main_template = PageTemplate(id = 'main_template', frames = [main_frame])
pdf_doc.addPageTemplates([main_template])
pdf_doc.build(story)