python - GRASS parser() error -
i'm trying use grass on python 2.7, i'm having problems @ setting script on idle, i'm getting error @ parser()
function:
here script:
import os import sys gisbase = os.environ['gisbase'] = 'c:\program files (x86)\grass gis 7.0.1rc1' gisrc = 'c:\grassdata' gisdbase = 'c:\grassdata' location = 'newlocation' mapset = 'tc' ld_library_path = 'c:\program files (x86)\grass gis 7.0.1rc1\lib' path = 'c:\program files (x86)\grass gis 7.0.1rc1\etc';'c:\program files (x86)\grass gis 7.0.1rc1\etc\python';'c:\program files (x86)\grass gis 7.0.1rc1\lib';'c:\program files (x86)\grass gis 7.0.1rc1\bin';'c:\python27';'c:\program files (x86)\grass gis 7.0.1rc1\python27';'c:\program files (x86)\grass gis 7.0.1rc1\msys' pythonlib = 'c:\python27' pythonpath = 'c:\program files (x86)\grass gis 7.0.1rc1\etc\python' sys.path.append(os.path.join(os.environ['gisbase'], 'etc', 'python')) import grass.script grass grass.parser() #i'm stucking here
i'm getting error inside subprocess.py
:
p = subprocess.popen([prog, '-n'] + argv, stdout=subprocess.pipe)
the full error:
traceback (most recent call last): file "c:\users\ciro\desktop\teste_grass.py", line 19, in <module> grass.parser() file "c:\program files (x86)\grass gis 7.0.1rc1\etc\python\grass\script\core.py", line 680, in parser p = subprocess.popen([prog, '-n'] + argv, stdout=subprocess.pipe) file "c:\python27\arcgis10.1\lib\subprocess.py", line 679, in __init__ errread, errwrite) file "c:\python27\arcgis10.1\lib\subprocess.py", line 893, in _execute_child startupinfo) windowserror: [error 2] system cannot find file specified
what missing?
based on grass source, trying run g.parser.exe
unable find it. need set path environment variable correctly fix this.
you seem trying set system environment variables in bulk of code 1 in bash or batch scripts, if i'm not mistaken. setting , modifying python variables, tough. if want set environment variables other subprocesses (such grass) can see them, need modify os.environ
variable, e.g.
os.environ['pythonlib'] = ...
instead of
pythonlib = ...
coming problem path environment variable, updating sys.path.append(...)
, setting right locations in path = ...
line above. latter not have effect due reason mentioned above. should need add sys.path.append(path)
on top of rid of error seeing.
Comments
Post a Comment