Ask Your Question

Why askbot works with runserver, but fails with production server?

asked 2012-11-29 14:03:50 -0600

daveg gravatar image

updated 2012-11-29 14:09:31 -0600

Evgeny gravatar image

I'm trying to run askbot 0.7.44 under gunicorn. When I startup askbot using, it works:

$ python askbotsite/ runserver
Validating models...

WARNING!!! You are using a 'locmem' (local memory) caching backend,
which is OK for a low volume site running on a single-process server.
For a multi-process configuration it is neccessary to have a production
cache system, such as redis or memcached.

With local memory caching and multi-process setup you might intermittently
see outdated content on your site.

0 errors found
Django version 1.4.2, using settings 'askbotsite.settings'
Development server is running at
Quit the server with CONTROL-C.

But if I try to start it up using gunicorn_django, it fails (this worked in 0.7.43):

$ gunicorn_django 
2012-11-29 19:58:21 [25585] [INFO] Starting gunicorn 0.16.1
2012-11-29 19:58:21 [25585] [INFO] Listening at: (25585)
2012-11-29 19:58:21 [25585] [INFO] Using worker: sync
2012-11-29 19:58:21 [25589] [INFO] Booting worker with pid: 25589
2012-11-29 19:58:22 [25589] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/", line 469, in spawn_worker
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/workers/", line 100, in init_process
    self.wsgi =
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/app/", line 99, in wsgi
    self.callable = self.load()
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/app/", line 101, in load
    return mod.make_wsgi_application()
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/app/", line 36, in make_wsgi_application
    if get_validation_errors(s):
  File "/opt/askbot/local/lib/python2.7/site-packages/django/core/management/", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/opt/askbot/local/lib/python2.7/site-packages/django/db/models/", line 146, in get_app_errors
  File "/opt/askbot/local/lib/python2.7/site-packages/django/db/models/", line 61, in _populate
    self.load_app(app_name, True)
  File "/opt/askbot/local/lib/python2.7/site-packages/django/db/models/", line 76, in load_app
    app_module = import_module(app_name)
  File "/opt/askbot/local/lib/python2.7/site-packages/django/utils/", line 35, in import_module
  File "/opt/askbot/local/lib/python2.7/site-packages/django/contrib/admin/", line 6, in <module>
    from django.contrib.admin.sites import AdminSite, site
  File "/opt/askbot/local/lib/python2.7/site-packages/django/contrib/admin/", line 3, in <module>
    from django.contrib.admin import ModelAdmin, actions
ImportError: cannot import name actions
Traceback (most recent call last):
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/", line 469, in spawn_worker
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/workers/", line 100, in init_process
    self.wsgi =
  File "/opt/askbot/local/lib/python2.7/site-packages/gunicorn/app/", line 99 ...
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-08 07:20:15 -0600

tynesjo gravatar image

I confirm the same problem using askbot 0.7.47 and gunicorn 0.17.2

While not diagnosed I note the problem goes away, in my experience, if you add gunicorn as an installed app in and instead launch gunicorn using:

python ./ run_gunicorn
edit flag offensive delete link more


This issue is always related to python paths being different in the two environments as I said in my answer. It is a 100% deployment issue.

Evgeny gravatar image Evgeny  ( 2013-03-08 14:04:06 -0600 )edit

answered 2012-11-29 14:12:37 -0600

Evgeny gravatar image

This issue is probably always due to differences in python paths available for the development and production

You can try printing "sys.path" at the top of your and comparing output under the two environments.

Try adding something like:

import sys

Then check out console/error log.

edit flag offensive delete link more


Both commands are run from the same virtualenv:

daveg gravatar image daveg  ( 2012-11-29 14:46:03 -0600 )edit

Your python paths don't seem to be the same in the two cases.

Evgeny gravatar image Evgeny  ( 2012-11-29 17:57:42 -0600 )edit

So what would be the fix for it?

daveg gravatar image daveg  ( 2012-11-29 18:29:51 -0600 )edit

Maybe look at gunicorn documentation about setting python path. It is a common problem with deployments that path in the server environment are different from your development environment.

Evgeny gravatar image Evgeny  ( 2012-11-29 18:38:53 -0600 )edit

Downgraded to 0.7.43 and gunicorn_django is working again

daveg gravatar image daveg  ( 2012-11-29 19:09:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-11-29 14:03:50 -0600

Seen: 2,193 times

Last updated: Mar 08 '13