Django Heroku上的枕头不';行不通
我正在用Django1.4.3和Pillow2.0.0开发一个应用程序 我有一个上传图像文件的表单。Django Heroku上的枕头不';行不通,django,heroku,python-2.7,pillow,Django,Heroku,Python 2.7,Pillow,我正在用Django1.4.3和Pillow2.0.0开发一个应用程序 我有一个上传图像文件的表单。 调整大小并裁剪发布的图像文件后, 我想保存图像文件,但出现了错误 在django的本地测试服务器中,错误不会发生并且工作正常, 但在希罗库,错误发生了 你能告诉我一些建议吗? 下面是接收张贴图像的代码。 此外,我使用S3boto和django存储 def编辑照片(请求): if request.user.is_经过身份验证(): 如果request.method==“POST”: #将发布的图像
调整大小并裁剪发布的图像文件后,
我想保存图像文件,但出现了错误 在django的本地测试服务器中,错误不会发生并且工作正常,
但在希罗库,错误发生了 你能告诉我一些建议吗? 下面是接收张贴图像的代码。 此外,我使用S3boto和django存储
def编辑照片(请求):
if request.user.is_经过身份验证():
如果request.method==“POST”:
#将发布的图像暂时保存为UserProfile.image
posted_photo=请求.文件['posted_photo']
file\u content=ContentFile(posted\u photo.read())
profile=request.user.get_profile()
temp\u filename=“新建文件”+str(profile.id)+“\u”+posted\u photo.name
profile.image.save(临时文件名、文件内容)
#读取已发布的文件
data=profile.image.read()
im=Image.open(StringIO.StringIO(数据))
#剪贴图片
裁剪框=(10,10,300,300)
照片=照片.裁剪(裁剪框)
photo_comp=photo.resize((230230),Image.ANTIALIAS)
#保存图像
thum=StringIO.StringIO()
照片_comp.save(图姆,巴布亚新几内亚)
profile.image.save(“saved_image”+str(profile.id)+“.png”,ContentFile(thum.getvalue()))
#删除临时图像
默认存储。删除(“面/”+临时文件名)
返回重定向(“../”)
错误信息如下所示
TypeError at /manage/edit_photo
function takes at most 4 arguments (6 given)
Request Method: POST
Request URL: http://hogehoge.herokuapp.com/manage/edit_photo
Django Version: 1.4.3
Exception Type: TypeError
Exception Value:
function takes at most 4 arguments (6 given)
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/PIL/Image.py in _getencoder, line 395
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.4
Python Path:
['/app',
'/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.11.0.55/newrelic/bootstrap',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages',
'/app/.heroku/python/lib/python2.7/site-packages/PIL',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
对于任何发现这个问题的人
当同时安装PIL和枕头时(可能是由于隐藏的包装要求而无意中),可能会发生此
类型错误。您需要卸载PIL和Pillow,然后重新安装所需的软件。!枕头从2.0降到1.7.8,它工作了。可能是Python2和Python3的问题。我想说的是——你一定做错了什么事——这里没有很好的理由解释为什么它可以在本地而不是远程工作。与其改变枕头的版本,不如改变枕头的版本?你应该始终追求两种环境之间的平衡;从我的设置中删除“分发”。py修复了它
/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py in get_response
response = callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/app/movie_manager/views.py in edit_photo
photo_comp.save(thum, "png") ...
▶ Local vars
/app/.heroku/python/lib/python2.7/site-packages/PIL/Image.py in save
save_handler(self, fp, filename) ...
▶ Local vars
/app/.heroku/python/lib/python2.7/site-packages/PIL/PngImagePlugin.py in _save
ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)]) ...
▶ Local vars
/app/.heroku/python/lib/python2.7/site-packages/PIL/ImageFile.py in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig) ...
▶ Local vars
/app/.heroku/python/lib/python2.7/site-packages/PIL/Image.py in _getencoder
return encoder(mode, *args + extra) ...
▶ Local vars