[GRASS-dev] [GRASS GIS] #2189: PyGRASS Module does not work on Windows
GRASS GIS
trac at osgeo.org
Thu Feb 6 08:56:15 PST 2014
#2189: PyGRASS Module does not work on Windows
-------------------------+--------------------------------------------------
Reporter: annakrat | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: pygrass | Platform: MSWindows 8
Cpu: Unspecified |
-------------------------+--------------------------------------------------
Comment(by annakrat):
Replying to [comment:1 zarch]:
> Replying to [ticket:2189 annakrat]:
> > PyGRASS Module class is not working on Windows. It can't find the
command:
> >
> > {{{
> > import grass.pygrass.modules as pymod
> > region = pymod.Module("g.region")
> >
> > GrassError: 'Error running: `g.region --interface-description`.'
> > }}}
> >
> > If I enter the entire path of the command, it works:
> [[BR]]
>
> May be it is only a PATH problem? are you able to run the command from
the terminal?, I'm just using:
>
>
(http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/pygrass/modules/interface/module.py#L243)
> {{{
> # call the command with --interface-description
> get_cmd_xml = subprocess.Popen([cmd, "--interface-description"],
> stdout=subprocess.PIPE)
> }}}
> [[BR]]
>
> So from my understanding also:
>
> {{{
> core.run_command("g.region", "p")
> }}}
>
> Should not find the command. Someone has an idea why this is happening?
> Both are using the same python class, and both avoid to set any special
environmental variable...
run_command works. The difference is passing shell=True in Popen
([http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/core.py#L51
as here]) and adding this helps. Python documentation warns against using
this but we are using it anyway in script.py. I added it in r58902. I
haven't checked if there are other places in pygrass where it is needed.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2189#comment:2>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list