I've tried to find resources online to link and run my Python script externally from Grass GIS 7, however, I have not been successful. I found resources here that provide instructions (e.g., https://grasswiki.osgeo.org/wiki/GRASS_and_Python#MS-Windows), but this is my first time using Python, and I haven't been able to figure it out. I am using Grass GIS 7.0.4, iPython 3.5, and Windows 10.
I tried to set environment variables in iPython and IDLE (don't know if it matters which I use to link it with Grass) with the following code:
import os
import sys
gisbase = os.environ['GISBASE'] = 'C:\OSGeo4W\apps\grass\grass-7.0.4' #GISBASE needs to point the root of the GRASS installation directory
gisrc = 'GISRC= C:\Documents and Settings\Suzaku1\.grassrc6'
gisdbase = 'C:\Users\Suzaku1\Documents\grassdata'
location = 'demolocation'
mapset = 'PERMANENT'
LD_LIBRARY_PATH = 'C:\OSGeo4W\apps\grass\grass-7.0.4\lib'
PATH = 'C:\OSGeo4W\apps\grass\grass-7.0.4\etc';'C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python';'C:\OSGeo4W\apps\grass\grass-7.0.4\lib';'C:\OSGeo4W\apps\grass\grass-7.0.4\bin';'C:\Python27';'C:\OSGeo4W\apps\Python27';'C:\OSGeo4W\apps\grass\grass-7.0.4\scripts';'C:\OSGeo4W\bin';'C:\OSGeo4W\apps\Python27\Lib\site-packages'
PYTHONLIB = 'C:\Python27'
PYTHONPATH = 'C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python'
GRASS_SH = 'C:\OSGeo4W\apps\msys\bin\sh.exe'
sys.path.append(os.path.join(os.environ['GISBASE'], 'etc', 'python'))
import grass.script as grass
The gisrc variable links to a text document I created following the recommendation here (see Update#2). I saved the text file as 'grass.pth' and placed it in (C:\OSGeo4W\apps\python27\lib\site-packages). Not sure if my gisrc variable is correct here since it doesn't link to the location referenced in the code above: Problem with python script to control GRASS GIS from outside - How to import grass.script under Win 8.1?
When I run the code, I receive an error saying that, 'import grass.script as grass' importerror: no module named grass.script'.
What am I doing wrong?
I have iPython (v3.5) installed via Anaconda and a separate installation of Python that was provided with the Grass GIS 7 download (v2.7). Not sure if this matters for linking.