0
ImportError: Could not import settings 'settings.prod' (Is it on sys.path? Is there an import error in the settings file?)

I built this app back in 2013-2014, and it hasn't seen much maintenance since then. But there's a problem now, some AWS keys need to be changed, but I can't deploy the app.

git push heroku master results in a failed build unless I do

heroku config:set DISABLE_COLLECTSTATIC=0

So, I did that, knowing it would probably break the site, but it never even gets to that point, because then I find out I can't deploy until I upgrade to Cedar-14. Ok, so I do that, then push, and then I get ImportError on every dyno.

app/web.1: ImportError: Could not import settings 'settings.prod' (Is it on sys.path? Is there an import error in the settings file?): cannot import name _uuid_generate_random

app/celerybeat.1: ImportError: Could not import settings 'settings.prod' (Is it on sys.path? Is there an import error in the settings file?): cannot import name _uuid_generate_random

app/celeryd.1: ImportError: Could not import settings 'settings.prod' (Is it on sys.path? Is there an import error in the settings file?): cannot import name _uuid_generate_random 

So I read here that I need to update Kombu. Ok, so I do that. Now the same problem, but at the end of the errors, I see this:

cannot import name ResourceError

I've googled, and searched SO, can't find much mention of this error anywhere, and if I add Heroku, I get Zero results. When was the last time a search for an error code returned zero results?

The only thing I can think of is that I'm running a very old version of gunicorn, gunicorn==0.14.6, but I'm not 100% sure what upgrading will do, what other dependencies I'll need to unfreeze and update, or what the new command I should use in the Heroku Procfile should be, since the gunicorn_django command was deprecated and removed.

Any thought on how best to get this app updated, so I can deploy a simple settings change, would be greatly appreciated.

Here's the Procfile, in case this provides any additional context to the error:

web: gunicorn_django -b 0.0.0.0:$PORT -w 9 -k gevent --max-requests 250 --preload settings.prod
celeryd: python manage.py celeryd -E -B --loglevel=INFO --settings=settings.prod
celerybeat: python manage.py celerybeat -S djcelery.schedulers.DatabaseScheduler --settings=settings.prod
Anthony Roberts
  • 1,971
  • 1
  • 19
  • 34

1 Answers1

0

Answering my own question.

Credit first to mrooney for this post, which got me to the right place. The problem was Kombu, but updating this library takes me to dependency hell, where each upgrade causes some other dependency to break.

The initial issue was due to the automated build doing a collectstatic but not using my --settings=settings.prod flag, so doing heroku config:set DISABLE_COLLECTSTATIC=0 was the initial correct action. The successive issues were all unrelated to the initial issue. Fortunately, I'm hosting all my static files on S3, so the collectstatic command is not necessary.

The suggestion by mrooney was a couple of lines in the settings file to catch the missing _uuid_generate_random function, and assign a default value. I did end up needed to update gevent, but that upgrade didn't break anything else, and after that, the heroku build was successful.

I would like to add a shout out to the free PaperTrail addon for Heroku, without which I would have absolutely no idea how to troubleshoot issues. If you aren't using it, I suggest you start.

Wurd.

Anthony Roberts
  • 1,971
  • 1
  • 19
  • 34