Flask-Uploads 给出 AttributeError?
Flask-Uploads gives AttributeError?
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,我的代码哪一部分不正确?
dict.itervalues()
仅在 python2.x 中,我猜 flask-uploads 还不支持 3.x 而且 setup.py
也没有说它们支持 3.x
如您所见,由于调用了 dict.itervalues()
.
,Flask-Uploads 0.1.3 不支持 Python 3
我最近接任了 Flask-Uploads 项目的维护者,并接受了修复 this commit 中问题的 PR。
包含此修复程序的 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
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,我的代码哪一部分不正确?
dict.itervalues()
仅在 python2.x 中,我猜 flask-uploads 还不支持 3.x 而且 setup.py
也没有说它们支持 3.x
如您所见,由于调用了 dict.itervalues()
.
我最近接任了 Flask-Uploads 项目的维护者,并接受了修复 this commit 中问题的 PR。
包含此修复程序的 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