Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. CalledModuleError: Module run None ['g.gisenv', '-n'] ended with error Process ended with non-zer return code -1073741701. See errors in the (error) output.
  2.  
  3. import os, sys, subprocess
  4.  
  5. # define GRASS database, location and mapset
  6. gisdb = r'C:datagrass'
  7. location = "Country"
  8. mapset = "Solar"
  9.  
  10. # location of GRASS start script
  11. grass7bin = r'C:Program FilesQGIS2.18bingrass72.bat'
  12.  
  13. # query GRASS GIS itself for its GISBASE
  14. startcmd = [grass7bin, '--config', 'path']
  15. try:
  16. p = subprocess.Popen(startcmd, shell=False,
  17. stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  18. out, err = p.communicate()
  19. except OSError as error:
  20. sys.exit("ERROR: Cannot find GRASS GIS start script"
  21. " {cmd}: {error}".format(cmd=startcmd[0], error=error))
  22. if p.returncode != 0:
  23. sys.exit("ERROR: Issues running GRASS GIS start script"
  24. " {cmd}: {error}"
  25. .format(cmd=' '.join(startcmd), error=err))
  26. gisbase = out.strip(os.linesep)
  27.  
  28. # set GISBASE environment variable
  29. os.environ['GISBASE'] = gisbase
  30. os.environ['GISDBASE'] = gisdb
  31.  
  32. # define GRASS-Python environment
  33. grass_pydir = os.path.join(gisbase, "etc", "python")
  34. sys.path.append(grass_pydir)
  35.  
  36. # import GRASS Python bindings
  37. import grass.script as gscript
  38. import grass.script.setup as gsetup
  39.  
  40. # launch session
  41. rcfile = gsetup.init(gisbase, gisdb, location, mapset)
  42.  
  43. # example calls
  44. gscript.message('Current GRASS GIS 7 environment:')
  45. print gscript.gisenv()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement