Reportlab 无法使用生产服务器找到 _imaging 模块
我正在尝试将 django 应用程序推送到生产服务器,但由于某种原因它失败并显示:
导入错误:_imaging C 模块未安装
奇怪的是,当我在同一台计算机上使用开发服务器时,它工作得很好。 PIL 已安装,我可以在 shell 中手动导入 _imaging 模块。生产服务器使用Apache。有什么想法吗?
回溯(最近一次调用最后一次):
文件“C:\Python27\lib\site-packages\django\core\handlers\base.py”,第 111 行,在 get_response 中 响应 = 回调(请求,*callback_args,**callback_kwargs)
文件“C:/portal2\compliance\views.py”,第 91 行,在 show_statement 中 doc.build(故事, onFirstPage=firstPage, onLaterPages=otherPage)
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 1117 行,构建中 BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 877 行,构建中 self.clean_hanging()
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 510 行,在 clean_hanging 中 self.handle_flowable(self._hanging)
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 757 行,handle_flowable f.应用(自我)
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 140 行,应用中 getattr(doc,arn)(*args)
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 1093 行,handle_pageBegin 中 self._handle_pageBegin()
文件“C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py”,第 535 行,位于handle_pageBegin self.pageTemplate.onPage(self.canv,self)
文件“C:/portal2\compliance\views.py”,第 55 行,第一页 canvas.drawImage(img,0,0,8.5*英寸,11*英寸)
文件“C:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py”,第857行,在drawImage中 imgObj = pdfdoc.PDFImageXObject(名称, 图像, mask=mask)
文件“C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py”,第 2094 行,init self.loadImageFromA85(src)
文件“C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py”,第 2100 行,位于 loadImageFromA85 中 imagedata = 地图(string.strip,pdfutils.makeA85Image(源,IMG=IMG))
文件“C:\Python27\lib\site-packages\reportlab\pdfbase\pdfutils.py”,第 34 行,在 makeA85Image 中 raw = img.getRGBData()
文件“C:\Python27\lib\site-packages\reportlab\lib\utils.py”,第 658 行,在 getRGBData 中 annotateException('\nidentity=%s'%self.identity())
文件“C:\Python27\lib\site-packages\reportlab\lib\utils.py”,第 655 行,在 getRGBData 中 self._data = im.tostring()
文件“C:\Python27\lib\site-packages\PIL\Image.py”,第 532 行,tostring self.load()
文件“C:\Python27\lib\site-packages\PIL\ImageFile.py”,第 164 行,加载中 self.load_prepare()
文件“C:\Python27\lib\site-packages\PIL\ImageFile.py”,第 231 行,位于 load_prepare 中 self.im = Image.core.new(self.mode, self.size)
文件“C:\Python27\lib\site-packages\PIL\Image.py”,第 37 行,getattr raise ImportError("未安装_imaging C 模块")
导入错误:未安装 _imaging C 模块 身份=[ImageReader@0x4517a30 文件名='C:\portal2\pdf\Certification_fullframe.tif'] handle_pageBegin args=()
I'm trying to push a django app to the production server, but for some reason it fails and says:
ImportError: The _imaging C module is not installed
The weird part is that when I use the development server on the same machine, it works just fine. PIL is installed, and I can import the _imaging module by hand in the shell. The production server uses Apache. Any ideas?
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)File "C:/portal2\compliance\views.py", line 91, in show_statement
doc.build(Story, onFirstPage=firstPage, onLaterPages=otherPage)File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1117, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 877, in build
self.clean_hanging()File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 510, in clean_hanging
self.handle_flowable(self._hanging)File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 757, in handle_flowable
f.apply(self)File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 140, in apply
getattr(doc,arn)(*args)File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1093, in handle_pageBegin
self._handle_pageBegin()File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 535, in handle_pageBegin
self.pageTemplate.onPage(self.canv,self)File "C:/portal2\compliance\views.py", line 55, in firstPage
canvas.drawImage(img,0,0,8.5*inch,11*inch)File "C:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py", line 857, in drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2094, in init
self.loadImageFromA85(src)File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2100, in loadImageFromA85
imagedata = map(string.strip,pdfutils.makeA85Image(source,IMG=IMG))File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfutils.py", line 34, in makeA85Image
raw = img.getRGBData()File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 658, in getRGBData
annotateException('\nidentity=%s'%self.identity())File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 655, in getRGBData
self._data = im.tostring()File "C:\Python27\lib\site-packages\PIL\Image.py", line 532, in tostring
self.load()File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 164, in load
self.load_prepare()File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 231, in load_prepare
self.im = Image.core.new(self.mode, self.size)File "C:\Python27\lib\site-packages\PIL\Image.py", line 37, in getattr
raise ImportError("The _imaging C module is not installed")ImportError: The _imaging C module is not installed
identity=[ImageReader@0x4517a30 filename='C:\portal2\pdf\Certification_fullframe.tif']
handle_pageBegin args=()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PIL 应在使用它的库之前安装。我在
libimaging
上遇到了类似的问题 - 在 libimaging 之前没有安装 PIL,因此 libimaging 是在没有它的情况下编译的。解决方案是卸载 libimaging 并在系统中已存在 PIL 的情况下重新安装它。PIL should be installed before library which uses it. I got similar problem with
libimaging
- PIL wasn't installed before libimaging so libimaging was compiled without it. Solution was uninstall libimaging and install it again with PIL already present in system.找到答案了!
在 Windows 上的 Django 应用程序中使用 PIL 时出现问题
我必须安装预编译用于 mod-wsgi 的 PIL 版本。
Found the answer!
Trouble using PIL in Django app on Windows
I had to install a version of PIL that was precompiled to work with mod-wsgi.