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?
2 Answers 2
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
-
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– Sanjeewa2012年12月21日 19:44:43 +00:00Commented Dec 21, 2012 at 19:44
-
1Either run GRASS one time to auto-create the .grassrc6 file or create it manually. I have updated the wiki page accordingly.markusN– markusN2012年12月21日 19:48:50 +00:00Commented 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: asciiSanjeewa– Sanjeewa2012年12月21日 20:58:07 +00:00Commented 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.markusN– markusN2012年12月23日 14:14:09 +00:00Commented Dec 23, 2012 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.