Flask-Uploads给出了AttributeError?

时间:2015-11-21 07:16:21

标签: python python-3.x flask python-3.5 flask-uploads

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,))

以上是我的代码,但它给了我以下错误:

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'

我使用 Flask 0.10.1 Flask-Uploads 0.1.3 ,我的部分代码不正确?

2 个答案:

答案 0 :(得分:1)

dict.itervalues()仅在python2.x中,我认为即席上传不支持3.x而且setup.py也没有说他们支持3.x

答案 1 :(得分:1)

正如您所注意到的,由于调用dict.itervalues(),Flask-Uploads 0.1.3不支持Python 3。

我最近接手了Flask-Uploads项目的维护者,并接受了在this commit修复该问题的公关。

包含此修补程序的0.2.0版本尚未推送到Pypi,但在此之前,您可以直接从GitHub安装Python 3兼容版本:

pip install git+https://git@github.com/jeffwidman/flask-uploads.git

如果您遇到任何问题,问题跟踪器就在此处:https://github.com/jeffwidman/flask-uploads/issues