Difference between import in script and from interpreter

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Jul 19 05:57:32 EDT 2010


Steven D'Aprano wrote:
> On Mon, 19 Jul 2010 00:53:56 -0400, Edward Diener wrote:
>
>   
>> In a python script a:
>>
>> from xxx.yyy.zzz import aaa
>>
>> fails with the message:
>>
>> "ImportError: No module named xxx.yyy.zzz"
>>
>> but from within the python interpreter the same line succeeds. What
>> would be the causes of that ?
>>
>>  From within the python interpreter I have looked at sys.path and
>> xxx.yyy.zzz is definitely in the path ( off of site-packages ). So I am
>> not sure why this is failing within the python script.
>>     
>
> And how is sys.path different when you run it as a script?
>
>
>   
'' is not in sys.path when running a script.
'' is in sys.path by default within a interpreter.


JM



More information about the Python-list mailing list