Flask上传给出了AttributeError? [英] Flask-Uploads gives AttributeError?
问题描述
from flask import Flask
from flask.ext.uploads import UploadSet,configure_uploads,IMAGES
$ b $ app = Flask(__ name__)
app.config ['UPLOADED_PHOTOS_DEST'] ='/ home / kevin'
photos = UploadSet('photos',IMAGES)
configure_uploads(app,(photos,))
以上是我的代码,但是它给了我以下错误:
Traceback(最近一次调用的最后一个):
在< module>文件中的./main.py
configure_uploads(app,(photos,))
在配置上传文件
中的文件/usr/lib/python3.5/site-packages/flaskext/uploads.py,第197行should_serve =任何(s.base_url在Set_config.itervalues()中都是None)
AttributeError:'dict'对象没有属性'itervalues'
我正在使用 Flask 0.10.1 和 Flask-Uploads 0.1.3 ,哪部分代码不正确? / b>正如你注意到的,Flask-Uploads 0.1.3不支持Python 3,因为调用 dict.itervalues()
。
我最近接管了Flask-Uploads项目的维护者,并接受了一个PR来解决这个问题。 这个提交。
包含此修复的0.2.0版本尚未推送到Pypi,但在此之前,您可以安装所有与Python 3兼容的版本直接来自GitHub:
pre $ p $ git + https://git@github.com/jeffwidman/ flask-uploads.git
如果遇到任何问题,问题跟踪器在这里: https://github.com/jeffwidman/flask-uploads/issues
from flask import Flask
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES
app = Flask(__name__)
app.config['UPLOADED_PHOTOS_DEST'] = '/home/kevin'
photos = UploadSet('photos', IMAGES)
configure_uploads(app, (photos,))
The above is my code, however it gives me the following error:
Traceback (most recent call last):
File "./main.py", line 10, in <module>
configure_uploads(app, (photos,))
File "/usr/lib/python3.5/site-packages/flaskext/uploads.py", line 197, in configure_uploads
should_serve = any(s.base_url is None for s in set_config.itervalues())
AttributeError: 'dict' object has no attribute 'itervalues'
I'm using Flask 0.10.1 and Flask-Uploads 0.1.3, which part of my code is incorrect?
As you noticed, Flask-Uploads 0.1.3 doesn't support Python 3 due to the call to dict.itervalues()
.
I recently took over as maintainer of the Flask-Uploads project, and accepted a PR fixing the issue in this commit.
The 0.2.0 release which includes this fix hasn't been pushed to Pypi yet, but until that happens you can install the Python 3 compatible version straight from GitHub:
pip install git+https://git@github.com/jeffwidman/flask-uploads.git
If you hit any issues, the issue tracker is here: https://github.com/jeffwidman/flask-uploads/issues
这篇关于Flask上传给出了AttributeError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!