Discussion:
[Tutor] ImportError: cannot import name log
vishwajeet singh
2009-09-16 17:51:54 UTC
Permalink
Hi,

Below is the content of __init__.py

import sys
from django.core.signals import got_request_exception
from . import log
logger = log._get_logger()

def got_request_exception_callback(sender, **kwargs):
"""Logging all unhandled exceptions."""
type, exception, traceback = sys.exc_info()
logger.error(unicode(exception))
got_request_exception.connect(got_request_exception_callback)

My question here is that what does *from . import log* doing I can see a
module name log in the same folder.

This import statement is throwing an error ImportError: cannot import name
log.

Thanks for all your help
--
Cheers,
Vishwajeet
http://www.singhvishwajeet.com
steve
2009-09-17 15:11:19 UTC
Permalink
Hello Vishwajeet,
Post by vishwajeet singh
Hi,
Below is the content of __init__.py
import sys
from django.core.signals import got_request_exception
from . import log
logger = log._get_logger()
"""Logging all unhandled exceptions."""
type, exception, traceback = sys.exc_info()
logger.error(unicode(exception))
got_request_exception.connect(got_request_exception_callback)
My question here is that what does *from . import log* doing I can see a
module name log in the same folder.
The '.' notation is fairly new and also uncommon AFAIK
http://docs.python.org/tutorial/modules.html#intra-package-references
Post by vishwajeet singh
This import statement is throwing an error ImportError: cannot import
name log.
The reasons it can't import using this 'from . import' notation would be the
same as for any other import errors. Check your PYTHONPATH and paste the entire
traceback if it still does not work.

cheers,
- steve
--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
vishwajeet singh
2009-09-17 15:45:05 UTC
Permalink
Post by steve
Hello Vishwajeet,
Post by vishwajeet singh
Hi,
Below is the content of __init__.py
import sys
from django.core.signals import got_request_exception
from . import log
logger = log._get_logger()
"""Logging all unhandled exceptions."""
type, exception, traceback = sys.exc_info()
logger.error(unicode(exception))
got_request_exception.connect(got_request_exception_callback)
My question here is that what does *from . import log* doing I can see a
module name log in the same folder.
The '.' notation is fairly new and also uncommon AFAIK
http://docs.python.org/tutorial/modules.html#intra-package-references
This import statement is throwing an error ImportError: cannot import
Post by vishwajeet singh
name log.
The reasons it can't import using this 'from . import' notation would be
the same as for any other import errors. Check your PYTHONPATH and paste the
entire traceback if it still does not work.
cheers,
- steve
--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
Thanks steve for your help I was able to fix the probelm.
--
Cheers,
Vishwajeet
http://www.singhvishwajeet.com
Loading...