<div dir="ltr">Hi I compiled <span style="font-size:12.8px;color:rgb(85,85,85);white-space:nowrap">Grass 7.0 (with OpenMP) </span><span style="font-size:12.8px;color:rgb(85,85,85);white-space:nowrap">on a CENTOS 7 OS.</span><div><span style="font-size:12.8px;color:rgb(85,85,85);white-space:nowrap"><br></span></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap">everything works properly, but I'm not able to use PYGRASS</span></font></div><div><br></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap">here is my first part of the codes if I add import pygrass I have the error:</span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><b><div style> import pygrass</div><div style><br></div><div style>ImportError: No module named pygrass</div></b></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div>
<p style="margin:0px">#!/usr/bin/env python</p>
<p style="margin:0px"> </p>
<p style="margin:0px">import os</p>
<p style="margin:0px">import sys</p>
<p style="margin:0px">import subprocess</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">import datetime, time</p>
<p style="margin:0px">now = datetime.datetime.now()</p>
<p style="margin:0px">StartTime = time.clock()</p>
<p style="margin:0px">########### ########### ########### ########### ########### ########### ########### ########### ########### </p>
<p style="margin:0px">########### ########### ########### ########### ########### ########### ########### ########### ########### </p>
<p style="margin:0px"># path to the GRASS GIS launch script</p>
<p style="margin:0px"># Linux</p>
<p style="margin:0px">grass7bin_lin = 'grass70'</p>
<p style="margin:0px"># DATA</p>
<p style="margin:0px"># define GRASS DATABASE # add your path to grassdata (GRASS GIS database) directory "~</p>
<p style="margin:0px">gisdb = os.path.join(os.path.expanduser("/DATA4/"), "grassdata")</p>
<p style="margin:0px"># specify (existing) location and mapset</p>
<p style="margin:0px">location = "EUROPE"</p>
<p style="margin:0px">mapset = "LANDCOVER"</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">########### SOFTWARE</p>
<p style="margin:0px">if sys.platform.startswith('linux'):</p>
<p style="margin:0px"> # we assume that the GRASS GIS start script is available and in the PATH</p>
<p style="margin:0px"> # query GRASS 7 itself for its GISBASE</p>
<p style="margin:0px"> grass7bin = grass7bin_lin</p>
<p style="margin:0px"> </p>
<p style="margin:0px"># query GRASS 7 itself for its GISBASE</p>
<p style="margin:0px">startcmd = [grass7bin, '--config', 'path']</p>
<p style="margin:0px"> </p>
<p style="margin:0px">p = subprocess.Popen(startcmd, shell=False,</p>
<p style="margin:0px"> stdout=subprocess.PIPE, stderr=subprocess.PIPE)</p>
<p style="margin:0px">out, err = p.communicate()</p>
<p style="margin:0px">if p.returncode != 0:</p>
<p style="margin:0px"> print >>sys.stderr, "ERROR: Cannot find GRASS GIS 7 start script (%s)" % startcmd</p>
<p style="margin:0px"> sys.exit(-1)</p>
<p style="margin:0px">gisbase = out.strip('\n\r')</p>
<p style="margin:0px"> </p>
<p style="margin:0px"># Set GISBASE environment variable</p>
<p style="margin:0px">os.environ['GISBASE'] = gisbase</p>
<p style="margin:0px"># the following not needed with trunk</p>
<p style="margin:0px">os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'extrabin')</p>
<p style="margin:0px"># define GRASS-Python environment</p>
<p style="margin:0px">gpydir = os.path.join(gisbase, "etc", "python")</p>
<p style="margin:0px">sys.path.append(gpydir)</p>
<p style="margin:0px">########### ########### ########### ########### ########### ########### ########### ########### ########### </p>
<p style="margin:0px">########### ########### ########### ########### ########### ########### ########### ########### ########### </p>
<p style="margin:0px">########### DATA</p>
<p style="margin:0px"># Set GISDBASE environment variable</p>
<p style="margin:0px">os.environ['GISDBASE'] = gisdb</p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px"><br></p>
<p style="margin:0px">from IPython.display import Image</p>
<p style="margin:0px">from pprint import pprint</p>
<p style="margin:0px">from subprocess import PIPE</p>
<p style="margin:0px">import numpy as np</p>
<p style="margin:0px">from grass import script</p>
<p style="margin:0px">import subprocess</p>
<p style="margin:0px"><br></p>
<p style="margin:0px">#looking(script, '*command*')</p>
<p style="margin:0px"># import GRASS Python bindings (see also pygrass)</p>
<p style="margin:0px">import grass.script as gscript</p>
<div>import grass.script.setup as gsetup<font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"> </span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap">many thanks</span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap"><br></span></font></div><div><font color="#555555"><span style="font-size:12.8000001907349px;white-space:nowrap">Grazia</span></font></div></div>