import fails in non-interactive interpreter

Devin Jeanpierre jeanpierreda at gmail.com
Wed Jan 25 22:04:53 EST 2012


On Wed, Jan 25, 2012 at 9:25 PM, Brian <brian.brinegar at gmail.com> wrote:
> Under what situations would a module be available to through the
> interactive interpreter but not the non-interactive?

I don't know if it matches your situation, but one such case is this:

The interactive interpreter (and the interpreter with the -c flag) add
the current working directory ('') to the module import search path
(sys.path). Regular python execution does not. So modules in the
current working directory can always be imported from the interactive
interpreter, but not necessarily if you run python on a source file.

-- Devin



More information about the Python-list mailing list