__import__ problem

Kottiyath n.kottiyath at gmail.com
Sat Dec 6 15:42:57 CET 2008


Hi all,
   When I try to import a module via __import__, I am facing
ImportError. But, when I tried to import it via usual 'import', it
worked fine.
  Please see below:
            try:
                import exact
            except:
                logging.exception('Error during importing')

            try:
                code = __import__('exact')
            except:
                logging.exception('Is it still happening?')

  The error is as:
2008-12-06 20:06:59,328 ERROR Is it still happening?
Traceback (most recent call last):
  File "C:\django\test\..\test\basic\views.py", line 166, in getValue
    code = __import__('exact')
ImportError: No module named exact

  Could you please let me know why this is happening? I tried to
__import__ 'sys etc, and it worked fine. Is it due to some issue in
the path?

Regards
K



More information about the Python-list mailing list