8

I have GRASS 6.4.3 svn installed on 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 HOME=%USERPROFILE%
set LD_LIBRARY_PATH = %GISBASE%\lib
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%
set PYTHONLIB= C:\Python27;%PYTHONLIB%
set PYTHONPATH= %GISBASE%\etc\python;%PYTHONPATH%
rem Environmental variables for GRASS stand-alone installer
set GRASS_WISH=%GISBASE%\extrabin\wish.exe
set GRASS_PYTHON=python
set GRASS_PROJSHARE=%GISBASE%\proj
set GRASS_HTML_BROWSER=explorer
set GRASS_SH=%GISBASE%\msys\bin\sh.exe
set PYTHONHOME=%GISBASE%\Python27
set GDAL_DATA=%GISBASE%\share\gdal
set PROJ_LIB=%GISBASE%\proj
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%
set PATH=%GISBASE%\bin;%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?

Taras
35.7k5 gold badges77 silver badges151 bronze badges
asked Dec 21, 2012 at 12:27

2 Answers 2

6

Check this page; it may give you some idea how to set it up:

http://grasswiki.osgeo.org/wiki/GRASS_and_Python

-> Creating Python scripts that call GRASS functionality from outside

--> MS-Windows

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Dec 21, 2012 at 18:16
4
  • 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? Commented Dec 21, 2012 at 19:44
  • 1
    Either run GRASS one time to auto-create the .grassrc6 file or create it manually. I have updated the wiki page accordingly. Commented Dec 21, 2012 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 Commented Dec 21, 2012 at 20:58
  • Am I right that we discuss the same on the grass-user mailing list? However, Wiki page updated again. Commented Dec 23, 2012 at 14:14
2

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.

answered Dec 30, 2012 at 19:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.