linux python ioerror,python – IOError:在Linux上的ReportLab中使用matplotlib PNG“解压缩zip不可用”,适用于Windows...

我正在使用ReportLab打印matplotlib生成的图表.

我能够在我的Windows开发机器上做到这一点没有问题.但是,当我部署到Ubuntu服务器时,渲染失败并显示错误.我假设我错过了一个Python模块,但我不知道哪个模块.我相信我的开发机器和服务器上的Python,matplotlib,ReportLab和PIL的版本是相同的.

将matplotlib图(称为图表)转换为PNG并返回的代码:

img_stream = StringIO.StringIO()

chart.savefig(img_stream, format = 'png')

img_stream.seek(0)

return img_stream

使用图片的代码:

res_img = charts.CreateProjectionChart(doc.fund) #calls above code

if res_img:

img = ImageReader(res_img)

canvas.drawImage(img, FromLeft(first_col), FromTop(3.5, 2), width - (.1 * inch), 1.75 * inch, preserveAspectRatio=True, anchor='c')

在Windows上运行时,这是有效的.在Linux上运行时会产生以下错误:

File "/home/web-server/reports.py", line 913, in FirstPageSetup

canvas.drawImage(img, FromLeft(first_col), FromTop(3.5, 2), width - (.1 * inch), 1.75 * inch, preserveAspectRatio=True, anchor='c')

File "/usr/local/lib/python2.7/dist-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/pdfgen/canvas.py", line 840, in drawImage

rawdata = image.getRGBData()

File "/usr/local/lib/python2.7/dist-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/lib/utils.py", line 658, in getRGBData

annotateException('\nidentity=%s'%self.identity())

File "/usr/local/lib/python2.7/dist-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/lib/utils.py", line 648, in getRGBData

if Image.VERSION.startswith('1.1.7'): im.load()

File "/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/ImageFile.py", line 189, in load

d = Image._getdecoder(self.mode, d, a, self.decoderconfig)

File "/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg/Image.py", line 385, in _getdecoder

raise IOError("decoder %s not available" % decoder_name)

IOError: decoder zip not available

identity=[ImageReader@0x30336d0]

handle_pageBegin args=()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值