Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have GRASS 6.4.3svn installed in my machine running Windows 7. Also in my machine i installed Python 2.7.3 for Windows.Now i need to call GRASS libraries from Python and not within the Python shell in GRASS GUI itself. I set the environment variables in the env.bat for this. But connection fails. This is the env.bat i have:

set GISBASE=C:\Program Files\GRASS GIS 6.4.3svn



set PATH= %GISBASE%\etc;%PATH%
set PATH=%GISBASE%\Python27;%PATH%
set PATH=%GISBASE%\lib;%GISBASE%\bin;%GISBASE%\extralib;%GISBASE%\msys\bin;%PATH%
set PATH=C:\Python27;%PATH%


rem Environmental variables for GRASS stand-alone installer

set GRASS_WISH=%GISBASE%\extrabin\wish.exe
set GRASS_PYTHON=python

set GRASS_SH=%GISBASE%\msys\bin\sh.exe

set GDAL_DATA=%GISBASE%\share\gdal
set GEOTIFF_CSV=%GISBASE%\share\epsg_csv

set PATH=%GISBASE%\msys\bin;%PATH%
set PATH=%GISBASE%\extrabin;%GISBASE%\extralib;%PATH%
set PATH=%GISBASE%\tcl-tk\bin;%GISBASE%\sqlite\bin;%GISBASE%\gpsbabel;%PATH%

rem Path to the python directory --
rem set PYTHONHOME=%GISBASE%\Python27 
rem if "x%GRASS_PYTHON%" == "x" set GRASS_PYTHON=python 

Can somebody help me in rectifying the problem.

Cheers, Brian.

share|improve this question

Did you check this page? It may give you some idea how to set it up:

-> Creating Python scripts that call GRASS functionality from outside

--> MS-Windows

share|improve this answer
Yes. I modiefied the env.bat using the website. However i do not find .grassrc6 in the path given in the website (GISRC= C:\Documents and Settings\user\.grassrc6) or in any other path. Sometimes it may be the cause. Any idea about this? – Sanjeewa Dec 21 '12 at 19:44
Either run GRASS one time to auto-create the .grassrc6 file or create it manually. I have updated the wiki page accordingly. – markusN Dec 21 '12 at 19:48
I ran the GRASS again but the file was not created. My Current settings are: GSIDBASE=C:\users\kabs\My Document, Location=Spearfish60 and Mapset=user1. How to update to existing directory (i have created c:\users\grassdata) with location, mapset and especially GRASS_DB_ENCODING: ascii – Sanjeewa Dec 21 '12 at 20:58
Am I right that we discuss the same on the grass-user mailing list? However, Wiki page updated again. – markusN Dec 23 '12 at 14:14

When configuring python for grass I faced with same issue. I've found grassrc6 under APPDATA:

It doesn't matter what the file is called, so long as %GISRC% points to it and it contains the necessary settings.

The normal location for GRASS 6.x on Windows is: %APPDATA%\GRASS6\grassrc6

On Windows 7, a typical setting for %APPDATA% is C:\Users\\AppData\Roaming

It is written here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.