[GRASS-user] Problems with GRASS python code in osgeo4w

Moskovitz, Bob Bob.Moskovitz at conservation.ca.gov
Mon Jun 22 13:10:56 EDT 2009

Thanks for the info.  I didn't know about the assoc and ftype.  Looking at the output of these two commands, I see that my system is set up correctly.  

So, I still don't know why the grass.parser() is not working for me.  I even modified my program to use pdb to see what is happening.  The debugger is aborted right after I reach os.execvp("g.parser.exe", [name] + argv) in grass.py.  But if I use "python c:\osgeo4w\apps\grass\grass-6.4.0svn\scripts\m.dipslope.py --help", I get the expected results.

Bob Moskovitz
Research Analyst I
Seismic Hazard Evaluation Project
California Geological Survey

CONFIDENTIALITY NOTICE: This communication is intended only for the use of the individual or entity to which it is addressed. This message contains information from the State of California, California Geological Survey, which may be privileged, confidential and exempt from disclosure under applicable law, including the Electronic Communications Privacy Act. If the reader of this communication is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.

> -----Original Message-----
> From: Glynn Clements [mailto:glynn at gclements.plus.com]
> Sent: Friday, June 19, 2009 7:03 PM
> To: Moskovitz, Bob
> Cc: Grass-User (E-mail)
> Subject: Re: [GRASS-user] Problems with GRASS python code in osgeo4w
> Moskovitz, Bob wrote:
> > I'm trying to figure out how to write python scripts using grass.py
> > under osgeo4w.  I was hoping that python script (and the binary
> > commands) would behave similarly to the grass environment 
> on my Ubuntu
> > box.  You know...just type the command and the gui for that command
> > comes up.  What I have to do now is type "python
> > c:\osgeo4w\apps\grass\grass-6.4.0svn\scripts\m.dipslope.py" 
> instead of
> > just type "m.dipslope.py".  I've also notice that the command gui or
> > even the command help does not come up when you just enter 
> the command.
> > Ultimately I would like to put my commands in the QGIS GRASS module
> > tree.
> 1. Ensure that .py files are configured to be run with the Python
> interpreter. You should be able to double-click on a .py file in
> Explorer and have it run. This should be done by the Python installer,
> but I don't know if the OSGeo4W installer does this.
> If it isn't, you can use e.g.:
>   assoc .py=python.file
>   ftype python.file="C:\Program Files\Python25\python.exe" "%1"
> [Change the pathname to wherever Python is installed.]
> 2. The PATHEXT environment variable needs to contain ".PY" if you want
> to use "m.dispslope" rather than "m.dispslope.py". You can do this
> temporarily with:
> or you can make it persistent either using the Control Panel or
> through the registry.
> For the Control Panel in XP, it's:
> My Computer
>  Control Panel
>   System
>    Advanced (Tab)
>     Environment Variables
> For the registry, the system-wide setting is taken from the PATHEXT
> value of the key:
> HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
> Or you can override it for the current user by adding a PATHEXT value
> to the key HKCU\Environment
> -- 
> Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list