I am using Heroku with python and Flask. My app was working fine until I updated a few lines in my python application file. The app runs fine locally, but I now have the following error when I try to access my app:
"An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details."
My logs look something like this:
2012-10-03T17:40:26+00:00 heroku[web.1]: Process exited with status 1
2012-10-03T17:40:26+00:00 heroku[web.1]: State changed from starting to crashed
2012-10-03T17:51:25+00:00 heroku[web.1]: State changed from crashed to starting
2012-10-03T17:51:26+00:00 heroku[web.1]: Starting process with command `python presentation.py`
2012-10-03T17:51:26+00:00 app[web.1]: ImportError: No module named site
I am also no longer able to run python through heroku:
Cinnas-MacBook-Pro:infinite-fortress-4866 cinna$ heroku run python
Running `python` attached to terminal... up, run.1
ImportError: No module named site
The next thing I have tried to do is check my environment variables:
Cinnas-MacBook-Pro:infinite-fortress-4866 cinna$ heroku config
=== infinite-fortress-4866 Config Vars
LANG: en_US.UTF-8
LD_LIBRARY_PATH: /app/.heroku/vendor/lib
LIBRARY_PATH: /app/.heroku/vendor/lib
PATH: /app/.heroku/venv/bin:/bin:/usr/local/bin:/usr/bin
PYTHONHASHSEED: random
PYTHONHOME: /app/.heroku/venv/
PYTHONPATH: /app/
PYTHONUNBUFFERED: true
However, when I try to look inside the library directories, I get something like this:
Cinnas-MacBook-Pro:infinite-fortress-4866 cinna$ heroku run ls /app/.heroku/vendor/lib
Running `ls /app/.heroku/vendor/lib` attached to terminal... up, run.1
ls: cannot access /app/.heroku/vendor/lib: No such file or directory
I am not sure where to proceed at this moment. I miss my app, please help!
Additional information:
The problems all started when I added the following lines to my app.py code:
@app.route('/my_fb_graph',methods=['GET','POST'])
def my_fb_graph():
return render_template('my_fb_graph.html')
When I pushed the code and the app no longer worked. I then removed these lines of code, pushed the code again, and still got the same errors. The next thing I did was to completely remove the app.py file and try to a small test code which still did not work.
The root of the problem seems to be the error:
2012-10-03T17:51:26+00:00 app[web.1]: ImportError: No module named site
I was able to fix the problem, but still dont know why it occurred in the first place!
After a lot of experimentation, I ended up setting up a completely new app on Heroku. I checked the environment variables in the new app and got the following:
Cinnas-MacBook-Pro:thawing-temple-4323 cinna$ heroku config
=== thawing-temple-4323 Config Vars
FACEBOOK_APP_ID: ***
FACEBOOK_SECRET: ***
PATH: bin:/usr/local/bin:/usr/bin:/bin
PYTHONUNBUFFERED: true
Checking my original app (the broken one), I realized that new environment variables were somehow added in my last push as indicated by my logs:
2012-10-04T04:20:04+00:00 heroku[api]: Add PYTHONUNBUFFERED, PYTHONPATH, PYTHONHOME, LANG, LD_LIBRARY_PATH, PATH, PYTHONHASHSEED, LIBRARY_PATH config by ***@***
and by checking my environment variables:
Cinnas-MacBook-Pro:infinite-fortress-4866 cinna$ heroku config
=== infinite-fortress-4866 Config Vars
LANG: en_US.UTF-8
LD_LIBRARY_PATH: /app/.heroku/vendor/lib
LIBRARY_PATH: /app/.heroku/vendor/lib
PATH: /app/.heroku/venv/bin:/bin:/usr/local/bin:/usr/bin
PYTHONHASHSEED: random
PYTHONHOME: /app/.heroku/venv/
PYTHONPATH: /app/
PYTHONUNBUFFERED: true
I removed these new variables with the command:
heroku config:remove PYTHONPATH PYTHONHOME LANG LD_LIBRARY_PATH PYTHONHASHSEED LIBRARY_PATH
and my app started to work again. I've been pushing more code, and this problem has not occurred again.
I am still really curious why/how these variables were added in the first place since all I did was do a git push.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With