execute python script question

Piet van Oostrum piet at cs.uu.nl
Tue Mar 11 06:31:27 EDT 2008


>>>>> Gabriel Rossetti <gabriel.rossetti at mydeskfriend.com> (GR) wrote:

>GR> not a stupid question, I think that may be it. I tried setting PYTHONPATH
>GR> like Sam suggested and it worked, but I was unable to do it programmically.
>GR> I tried putting it in the __init__.py file like a web post suggested but it
>GR> wasn't run until after I set PYTHONPATH, and once that was done there is no
>GR> need (that I can see anyways) to set it in __init__.py.

The __init__.py is executed during your import statement, thus it is too
late to find MyPackage. You will have to change the sys.path before the
import, e.g. in your main program. Or do what is usually done: put
MyPackage in the site-packages directory.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list