Flask-Uploads gives AttributeError?

2024/10/14 22:20:41
from flask import Flask
from flask.ext.uploads import UploadSet, configure_uploads, IMAGESapp = 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_uploadsshould_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?

Answer

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://[email protected]/jeffwidman/flask-uploads.git

If you hit any issues, the issue tracker is here: https://github.com/jeffwidman/flask-uploads/issues

https://en.xdnf.cn/q/117904.html

Related Q&A

Python: Alternate way to covert from base64 string to opencv

Im trying to convert this string in base64 (http://pastebin.com/uz4ta0RL) to something usable by OpenCV. Currently I am using this code (img_temp is the string) to use the OpenCV functions by convertin…

Move 3D plot to avoid clipping by margins

Im trying to figure out how I can get the 3D matplotlib images below to plot higher on the canvas so it doesnt get clipped. Here is the code Im using to create the plot. I couldnt find a way to attach …

HTML Link parsing using BeautifulSoup

here is my Python code which Im using to extract the Specific HTML from the Page links Im sending as parameter. Im using BeautifulSoup. This code works fine for sometimes and sometimes it is getting st…

XML format change using XSL file in a Python code

Have written a Python code to transform a XML file to a particular format using XSL stylesheet. Python code below:#!/usr/bin/env python # -*- coding:utf-8 -*- from lxml import etree def transform(xmlP…

How to extract a specific value from a dictionary in python

I want to extract distance from google distance matrix API in Python. The objet it returned is a python dictionary.{destination_addresses: [Mumbai, Maharashtra, India ],origin_addresses: [Powai, Mumbai…

label on top of image in python

I am trying to display text on top of an image. Right now the text is below the image or if I put a row=0 in the grid disappears. I am assuming it is behind the image. I cant seem to get it to work. My…

plot multiple graphs from multiple files gnuplot

I have a set of files named like this:qd-dPZ-z1-1nn.dat qd-dPZ-z2-1nn.dat qd-dPZ-z4-1nn.dat qd-dPZ-z8-1nn.dat qd-dPZ-z16-1nn.dat qd-dPZ-z32-1nn.dat qd-dPZ-z1-2nn.dat qd-dPZ-z2-2nn.dat qd-dPZ-z4…

Python writing to CSV... TypeError: coercing to Unicode: need string or buffer, file found

outputList is a list of lists. [ [a,b,c], [d,e,f], [g,h,i] ] and I want to output it to a csv file with each list as a separate row. Im getting this error TypeError: coercing to Unicode: need string or…

Preserve Signature in Decorator python 2

I am writing a decorator which will catch TypeError for incorrect number of arguments in a function call and will print a customised message. The code is here:import inspectdef inspect_signature(f):def…

Gimp: start script without image

Well, Im trying to write a python plug-in for Gimp, but it wont start without first loading an image... What can I do about that?