[GRASS-user] Re: [GRASS-windows] WinGRASS Python 2.7

Glynn Clements glynn at gclements.plus.com
Thu Sep 8 03:43:50 EDT 2011

Johannes Radinger wrote:

> So what I tried now were three different settings in the env.bat

Ugh. Init.bat ignores GRASS_PYTHON and just uses "python":

	python "%GISBASE%/etc/wxpython/gis_set.py"
	if %errorlevel% == 2 goto exitinit
	python "%GISBASE%/etc/wxpython/wxgui.py"

That should probably be:

	"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/gis_set.py"
	if %errorlevel% == 2 goto exitinit
	"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/wxgui.py"

GRASS_PYTHON is honoured by g.gui, the dialogs generated by the
parser, and the Unix start-up script, but not by Init.bat.

> Just to inform you why I need that: I wrote a .py script (including
> g.parser elements) which I want to call inside GRASS with "file.py"

Note that if you add .PY to PATHEXT, e.g.:


you can omit the ".py" suffix when running the script. This is the
preferred approach, for portability reasons. In 7.0 (where the shell
scripts have been replaced with Python scripts), the scripts are
installed with the .py suffix on Windows but without the suffix on
Unix. So the only portable way to run a Python script is to omit the
suffix and to rely upon PATHEXT on Windows.

> (like any other modules e.g. r.fuzzy etc.) The script is working
> (tested on my Mac using GRASS in combination with Python 2.7)! The
> script calls scipy which can only be used in combination with Python
> 2.6 or newer (so far as I remember).

Note that the Python version used for scripts isn't tied to the
version used for the GUI or for the parameter dialogs (in fact, if
GRASS_GUI is set to tcltk, even Python scripts will use Tcl/Tk for the
parameter dialogs).

GRASS_PYTHON is only for the GUI and the parameter dialogs. It exists
because the GUI originally needed to use a specific version of Python
(for compatibility with binary components) which might not be the
"system" version.

On Unix (and from MSys' bash on Windows), scripts use the program
specified in the #! line (for "#!/usr/bin/env python", this will be
the first version found in the path). On Windows, they use the file

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list