0
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?

Remi Guan
  • 21,506
  • 17
  • 64
  • 87

2 Answers2

1

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

lord63. j
  • 4,500
  • 2
  • 22
  • 30
  • Really? I installed it by `pip`, and there's no error or warning, also I didn't find it in the document...So that is unless I use python2 run the script, I'm not able to use flask-uploads right? – Remi Guan Nov 21 '15 at 07:32
  • Install it successfully doesn't mean that we can use it. Sadly, python3.x don't support `dict.itervalues()`, you can try it youself, I'm afraid that you can't use it. Maybe you can file an issue there, wait the author to port it. – lord63. j Nov 21 '15 at 07:35
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

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Jeff Widman
  • 22,014
  • 12
  • 72
  • 88
  • Cool and thanks! So that means Flask-Uploads 0.2.0 now support Python 3? – Remi Guan Dec 15 '15 at 10:14
  • Yes, I haven't actually tagged the release because I just made a bunch of changes to modernize it and I'd like to have a few folks try it out and make sure nothing slipped through the cracks before I actually push it out to Pypi. All tests pass just fine, but I just started maintaining it, so not sure how reliable the test suite is. So try it out and file an issue if you run into anything. – Jeff Widman Dec 15 '15 at 10:17
  • Ah, just tried it and it works perfect! Thanks for the new version of Flask-Uploads :D – Remi Guan Dec 15 '15 at 10:30
  • Awesome. Thanks for letting me know. – Jeff Widman Dec 15 '15 at 10:42
  • Please push this to PyPi. – shuttle87 Apr 26 '18 at 14:46