Question
Flask Deployment on Ubuntu 12.04 - 500 Error, logs: ImportError cannot import name Flask
I’ve followed this tutorial pretty much to the letter:
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps
When I’m in the virtualenv, and running the Flask app on the localhost, I am able to:
curl localhost:5000
and receive a 200 http response “hello world”
But when I try to access the site from my browser, I get the following error log.
root@barchief:/var/www/flask# tail /var/log/apache2/error.log
[Wed Jul 09 09:34:57 2014] [notice] caught SIGTERM, shutting down
[Wed Jul 09 09:34:58 2014] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] mod_wsgi (pid=10918): Target WSGI script '/var/www/flask/flask.wsgi' cannot be loaded as Python module.
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] mod_wsgi (pid=10918): Exception occurred processing WSGI script '/var/www/flask/flask.wsgi'.
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] Traceback (most recent call last):
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] File "/var/www/flask/flask.wsgi", line 10, in <module>
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] from flask import app as application
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] File "/var/www/flask/flask/__init__.py", line 1, in <module>
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] from flask import Flask
[Wed Jul 09 09:35:02 2014] [error] [client 166.147.104.146] ImportError: cannot import name Flask
I’m getting an ImportError for Flask, but flask has to be installed because I’m able to access it from localhost. What should I do?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×