Flask-Uploads gives AttributeError?

心不动则不痛 提交于 2019-12-12 02:43:25

问题


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?


回答1:


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




回答2:


dict.itervalues() is only in python2.x, I guess flask-uploads don't support 3.x yet and the setup.py also don't say that they support 3.x



来源:https://stackoverflow.com/questions/33840765/flask-uploads-gives-attributeerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!