Forums

django 1.4 unhandled exception

ok so this is my first time upload my web app, so excuse my newbieness.

I'm using django 1.4, got an error then i follow this https://www.pythonanywhere.com/forums/topic/123/ .Then i type 'python manage.py syncdb' and it works. But when i try open my web, it says : 'Unhandled exception, An unhandled exception was thrown by the application. '

Can anyone give me a hand bout this? thx

Hello farisnasution,

Well that's good in one way. It means that you are almost there. The actual stack trace / error message that is generating this exception can be found in your error.log which is linked to from the Web tab or can be found in /var/logs/apache2/error.log. If you have a look at that log you'll probably find quite a few error messages. The one that interests you now will always be the one at the end. Have a look at that and if you can't figure out what the error is then come back here and post the specific error message.

Cheers

I keep having the same problem, and in the error log doesn't show anything about it. Initially I thought it was because of the url design, but I keep having it even if I change the design of the url.

Does anybody know about possible causes of this problem? Any help will be appreciated

Hi Arkmol -- I just took a look at your error logs, and there is something there -- every time someone hits your site, it says "TemplateSyntaxError: Caught ImportError while rendering: No module named XXXXX" (I've replaced the module name with XXXXX just in case it's private.)

You can see this yourself at https://www.pythonanywhere.com/user/Arkmol/files/var/log/apache2/error.log. One warning -- the timestamps on your logfiles seem to be UTC-5 -- perhaps that was what was confusing you? I'll take a look at that and try to work out why it's happening, anyway.

Hi PA team!

I really like your service and currently trying to find whether not only prototyping can be done with it (after moving to a paid account).

Right now I am struggling with an issue which fit's into this current thread.

I deployed my application on PA and was able to run the application till today. I started to get suddenly the following message

Unhandled Exception

In the error log I can see the following

2012-08-22 04:19:42,073 :Traceback (most recent call last): 2012-08-22 04:19:42,074 :KeyError: 'PATH' 2012-08-22 04:19:46,696 :Traceback (most recent call last): 2012-08-22 04:19:46,697 :KeyError: 'PATH' 2012-08-22 04:19:46,916 :Traceback (most recent call last): 2012-08-22 04:19:46,917 :KeyError: 'PATH' 2012-08-22 04:23:25,745 :Traceback (most recent call last): 2012-08-22 04:23:25,746 :KeyError: 'PATH'

I have no idea what is wrong with the application. When I am creating a new application things are working fine. Any ideas what went wrong or can you give me some hints how to debug the issue?

Thx in advance --Roman

@Roman: Does this project have any debug logging included in the code? If so, this could be a good time to turn it on so you could possibly determine the area of your code where this is happening. I'd love to offer more, but at this point, I don't have a single line of source code or anything else but these tracebacks to base a response on. Hopefully you can provide more information or someone else will just happen to have insights to offer you from personal experience commonly seeing this particular error. I just know I'm glad to say I haven't seen this one.

Even if you don't have any logging included in your project, this could be a good time to tinker with it a bit if you care to. Maybe just add a couple of log entries where you are dealing with key data. Or better yet, just prior to and just after to conclude where your code it is exiting.

Depending on the Python version you are using, the docs for the logging module are here for 2.7 and 3.2.

In the event you are considering adding some logging and you've never used it before, the above links include some decent tutorials to get you pointed in the Pythonic direction...☺

I wish I could be more help and I really hope you get this issue resolved quickly and painlessly!

Hi Roman,

It looks like that's a problem we caused when we switched to nginx/uwsgi - we were removing the PATH environment variable, which is needed for some virtualenv setups.

I've temporarily fixed it at our end, which will work until you hit "reload web app". We're going to work on a more permanent fix, hopefully that will get out later today or tomorrow...

In the meantime, if you want to hit "reload web app", find the file at ~/Envs/django/bin/activate_this.py in your home dir, and change it so that line 16 says

old_os_path = os.environ.get('PATH', '')

Hello Harry,

Thank you for fixing the issue. Yeah, did not expect that your changes were impacting my virtualenv. In case of using your paid service and running an application, it would be a bad thing if the application breaks during maintenance work. Do you guys are treating paid customers differently? As mentioned in case we are considering to switch to the paid solution it is very important to find out how you are doing maintenance updates and possible downtimes.

Thanks again for looking and fixing the issue!

--Roman

Hi Roman, Backwards compatibility is absolutely important to us. This was an oversight rather than something intentional. We hot fixed it last night. So thanks very much for bringing it to our intention. Harry's temporary fix should no longer be required.

Cheers

Hansel

I have the same problem, when I try to visit myuser.pythonanywhere.com i get the same error: Unhandled exeption.. I have modified wsgi, and settings accordingly.. when I run python manage.py syncdb, to get it running, i get following error:

 File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 92, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'project_name.settings' (Is it on sys.path?): No module named settings

What am I doing wrong?

[edit by admin: formatting]

Can I take a look at your files? We can see them from our side, but we never look without permission.

Yes, please. But I`ve made some changes.. but only to wsgi and setting

OK, so it's a Django 1.4 app. Are you using a virtualenv? The system default Django for Python 2.7 is verison 1.3, so you need a virtualenv to get 1.4 to work. Here's a tutorial.

Same error...

Does this help? https://www.pythonanywhere.com/wiki/DebuggingImportError

Where you mention project_name.settings above, matej, is that you've replaced your project's name with "project_name"? Or does the message literally read project_name.settings? I wonder if there's some textual substitution that was supposed to have happened but didn't...?

@harry .. no, I have changed project_name to real project name... Ok, I do not know django as such, is it possible, I have used Django 16 with virtualenv, but app is Django 1.4.. could this cause an error?

OK. Have a look at the debugging help that harry posted above and let us know the results.