Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Using uWSGI to serve a simple wsgi app, (a simple "Hello, World") my configuration works, but when I try to run a Flask app, I get this in uWSGI's error logs:

current working directory: /opt/python-env/coefficient/lib/python2.6/site-packages
writing pidfile to /var/run/uwsgi.pid
detected binary path: /opt/uwsgi/uwsgi
setuid() to 497
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)  [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)]
Set PythonHome to /opt/python-env/coefficient/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xbed3b0
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
added /opt/python-env/coefficient/lib/python2.6/site-packages/ to pythonpath.
unable to find "application" callable in file /var/www/coefficient/flask.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***`

Note in particular this part of the log:

unable to find "application" callable in file /var/www/coefficient/flask.py

unable to load app 0 (mountpoint='') (callable not found or import error)

**no app loaded. going in full dynamic mode**

This is my Flask app:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World, from Flask!"

Before I added my Virtualenv's pythonpath to my configuration file, I was getting an ImportError for Flask. I solved this though, I believe (I'm not receiving errors about it anymore) and here is my complete configuration file:

uwsgi:
  #socket: /tmp/uwsgi.sock 
  socket: 127.0.0.1:3031
  daemonize: /var/log/uwsgi.log
  pidfile: /var/run/uwsgi.pid
  master: true
  vacuum: true
  #wsgi-file: /var/www/coefficient/coefficient.py
  wsgi-file: /var/www/coefficient/flask.py
  processes: 1
  virtualenv: /opt/python-env/coefficient/
  pythonpath: /opt/python-env/coefficient/lib/python2.6/site-packages

This is how I start uWSGI, from an rc script:

/opt/uwsgi/uwsgi --yaml /etc/uwsgi/conf.yaml --uid uwsgi

And if I try to view the Flask program in a browser, I get this:

**uWSGI Error**

Python application not found

Any help is appreciated.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

unable to find "application" callable in file /var/www/coefficient/flask.py

is the key :)

Your app is defining an 'app' callable, so you have to instruct uWSGI to search for it, instead of 'application'.

You can use the option

callable: app

and it will works (this is explained in official Flask docs)

share|improve this answer
    
You're correct: setting callable: app fixed it, and as you said, this in the Flask docs. Strangely, though, on another uWSGI install, using the same Python code, I did not have to specify callable: app; it just worked out of the box. –  skyler Aug 1 '12 at 14:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.