Forums

Error running WSGI application - Django

I can't seem to get past the following error:

2015-12-19 11:31:23,332 :/usr/lib/python2.7/threading.py:1160: RuntimeWarning: tp_compare didn't return -1 or -2 for exception

2015-12-19 11:31:23,332 : return _active[_get_ident()]

2015-12-19 11:31:23,330 :Error running WSGI application

None

2015-12-19 11:31:29,677 :Error running WSGI application

None

2015-12-19 11:31:29,799 :Error running WSGI application

None

This previous post had an identical error and I tried the following suggestions:


python /var/www/sales-rank-staging_trevorwatson_me_wsgi.py

Runs with no problem.


python manage.py shell

Also no problems.


path = '/home/cfc/sites/sales-rank-staging.trevorwatson.me/source'
...
os.environ['DJANGO_SETTINGS_MODULE'] = 'sales_rank_site.settings'

Verified paths are correct.


pip freeze
Django==1.9
requests==2.9.0
scrapinghub==1.7.0
selenium==2.48.0
wheel==0.24.0

The packages installed varied from my requirements file by not including argparse==1.2.1 & wsgiref==0.1.2, so I tried:

pip install argparse==1.2.1
Requirement already satisfied (use --upgrade to upgrade): argparse==1.2.1 in /usr/lib/python2.7
pip install wsgiref==0.1.2
Requirement already satisfied (use --upgrade to upgrade): wsgiref==0.1.2 in /usr/lib/python2.7

Any other suggestions?

hmm- if scrapinghub tries to create threads, this is not going to work with your webapp. (but it will work as a scheduled task or as a console command)

scrapinghub is just a library to access their api to run scrapy on their servers, but I uninstalled it to see if it had any effect... no luck. Any ideas on where to start troubleshooting? The error really doesn't offer much to go on.

Worked it out... the secret_key was being retrieved from environment variables, but the postactivate script doesn't set the variables for webapps.

Yes, we must write up a quick guide to setting environment variables for web apps...

I've tried to write up a quick guide. Feedback please! https://help.pythonanywhere.com/pages/environment-variables-for-web-apps

Sweet! Looks good. Is 'export' necessary preceding the variable or is that only necessary when setting it directly in a bash console? e.g.

export SECRET_KEY="mysekritvalue"

@cfc, I think export is needed, you're right. thanks very much for picking up on that :)

fixed!