Windows System Error
I'm trying to use your wonderful code on Windows but getting a System Error:
g.list.exe - System Error
The code execution cannot proceed because libgrass_vector.7.4.0.dll was not found.
Reinstalling the program may fix this problem.
This is caused from the following script. Everything works until the last g.list line:
grass7bin = r'"C:\Program Files\GRASS GIS 7.4.0\grass74.bat"'
import os
os.environ['GRASSBIN'] = grass7bin
from grass_session import Session
from grass.pygrass.modules.shortcuts import general as g
PERMANENT=Session()
PERMANENT.open(gisdb="C:\Users\<user>\Documents\GRASS_database", location="G", mapset="PERMANENT", create_opts="")
g.list(type="raster")
I'm running this from within IPython inside Spyder. The same (rough) code works when I do it on OS X.
Hi @mankoff, sorry for the silence... it has been a busy period... :-P
Unfortunatelly, I have not chance to test the code on a windows machine, but from the error that you provide, it seems like windows don't know in which directory can find the grass ddls. Probably the error is due to a wrong environmental variable setting up the path.
If you open in a grass shell a python interpreter and execute the following lines:
import os
for key in sorted(os.environ.keys()):
print("{} => {}".format(key, os.environ[key]))
Then execute the same line within the grass-session, so for instance:
grass7bin = r'"C:\Program Files\GRASS GIS 7.4.0\grass74.bat"'
import os
os.environ['GRASSBIN'] = grass7bin
from grass_session import Session
from grass.pygrass.modules.shortcuts import general as g
PERMANENT=Session()
PERMANENT.open(gisdb="C:\Users\<user>\Documents\GRASS_database", location="G", mapset="PERMANENT", create_opts="")
for key in sorted(os.environ.keys()):
print("{} => {}".format(key, os.environ[key]))
Using a difftool (e.g. meld) or just comparing the outputs you should be able to identify which environmental variable is not set correctly or which relevant environmental variable is missing. If you can provide to me the information of what is not correct I would glad to fix this issue.