0

I am working on setting up the front end of a database to track theater costumes in Flask. Users need to be able to upload picture of the costumes, and I am attempting to use Flask-Uploads for this. I installed Flask Uploads and Flask Storage using these two commands:

pip install flask-uploads
pip install flask-storage

They seem to have installed correctly, but they depend on urllib2, which doesn't work properly. I'm not sure how to resolve these dependency errors from the downloaded apps. The error log is below.

    File "/srv/http/projects/costumes/costume.wsgi", line 3, in <module>
     from costumeServer import app as application
   File "/srv/http/projects/costumes/costumeServer.py", line 6, in <module>
     from flask.ext.storage import get_default_storage_class
   File "/usr/lib/python3.5/site-packages/flask/exthook.py", line 81, in load_module
     reraise(exc_type, exc_value, tb.tb_next)
   File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 32, in reraise
     raise value.with_traceback(tb)
   File "/usr/lib/python3.5/site-packages/flask_storage/__init__.py", line 17, in <module>
     from ._base import *
   File "/usr/lib/python3.5/site-packages/flask_storage/_base.py", line 13, in <module>
     import urllib2
 ImportError: No module named 'urllib2'

I tried installing urllib2 with

pip install urllib2

but that made no difference.

Jeff Widman
  • 22,014
  • 12
  • 72
  • 88
  • 5
    `urllib2` was part of the standard library that was removed in Python 3. Flask-Storage isn't compatible with Python 3. You'll either need to pick a different library, do it yourself, or use Python 2 instead. – dirn Nov 11 '15 at 23:53
  • The Flask docs say that "Flask and all of its dependencies support Python 3" ( http://flask.pocoo.org/docs/0.10/python3/ ) Is that not true? The Python3 version of pip seems perfectly happy to install them all—does the Python3 package database include packages that are Python2 only? – blahedo Nov 12 '15 at 16:12
  • Is there another similar library that is compatible with Python 2 that you could recommend? – RevvyTheWolf Nov 16 '15 at 20:41
  • FYI: Flask-Uploads is now Python 3 compatible due to this commit: https://github.com/jeffwidman/flask-uploads/commit/231687b9084adde181b26923784a73008b38be8e No idea about Flask-Storage – Jeff Widman Dec 15 '15 at 10:19

0 Answers0