why _import__ only works from interactive interpreter?

linuxnow at gmail.com linuxnow at gmail.com
Sun May 7 18:46:36 EDT 2006


I don't know what I'm doing wrong, but the result is that _import_ only
works from a python shell, but not when I call a python script.

$ cat test.py
mod = __import__("/home/me/tests/test_imp")

Called from a script it does not work:
$ python /home/me/test.py
Traceback (most recent call last):
  File "/home/pau/test.py", line 1, in ?
    mod = __import__("/home/me/tests/test_imp")
ImportError: No module named /home/me/tests/test_imp

But if I import it from a python shell, then no problem:
$ python 
>>> import test
>>> 

What am I doing wrong?




More information about the Python-list mailing list