[GRASS-dev] PYTHONPATH question

Glynn Clements glynn at gclements.plus.com
Mon Jul 28 08:44:25 EDT 2008


Michael Barton wrote:

> > Is there any pattern to which modules will import and which won't?
> 
> All the paths in sys.path are valid.

That isn't what I asked.

Which modules will import, and which won't? Presumably "sys" imports
(that's built into Python)? What about "os"?

Is it just the modules in site-packages, or the "system" modules as
well?

> AFAICT, everything works without $PYTHONPATH in all cases EXCEPT in
> a script running under the GRASS parser.

So what changes before and after g.parser?

In the scripts which I have seen so far, the imports are at the top
level, so they will be executed on both occasions. I can't think of
any reason why an import would fail when the script is run initially
but then work when the script is re-invoked from g.parser.

Can you add commands to print sys.argv and sys.path (and, if you can
import "os", os.environ) to the top of the script, and see what is
changing before and after g.parser.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list