I am using grass 7.8.4. I'm trying to run some simple commands using the Grass Python Scripting Library in Python. For modules for which the source code is written in C++ or any other language than Python, it works without problem but for the modules written in Python it does not. Here is an example of a simple command I tried to run:
import grass.script as gscript
gscript.run_command("v.db.dropcolumn", flags="help")
It raises the error:
grass.exceptions.CalledModuleError: Module run None v.db.dropcolumn --help ended with error.
Process ended with non-zero return code 9009
I already checked and I know that return code 9009 means it does not find the python script. I solved the error by just adding ".py" in the command:
gscript.run_command("v.db.dropcolumn.py", flags="help")
I would like the command to work without the ".py" because I'm writing a python script that makes use of some addons. For the addons to work in my python script I sometimes need to modify them because there are running commands like "v.db.dropcolumn" without the ".py", so I have to add it. But then, the addons do not work anymore when I use them directly in the grass GUI. Does anybody know how to solve this?
gscript.run_command('g.region', flags='p')does it work or does this raise an error too? – F.H. Jan 14 '21 at 18:05gscript.run_command('g.region', flags='p')runs without any problem. It raises an error for all the modules written in python – Camille Morlus Jan 14 '21 at 19:33gscript.run_command("v.db.dropcolumn", help=True). Please try it and let me know if the error is still present. – F.H. Jan 14 '21 at 20:23import grass.script as gscriptfrom grass.pygrass.modules import Modulefrom grass.pygrass.modules.shortcuts import general as gfrom grass.pygrass.modules.shortcuts import vector as vfrom grass.pygrass.modules.shortcuts import raster as rfrom grass.pygrass.modules.shortcuts import imagery as ii) – F.H. Jan 14 '21 at 20:25gscript.run_command("v.db.dropcolumn", help=True)and it does not change anything, I still get the same error. I don't think it is related to the help flag because for instance installing an extension produces the same error as well (when usinggscript.run_command("g.extension.py", extension="v.class.mlR")for instance). I didn't use pygrass because I'm new to grass and I didn't think about it.. thank you for the tips! How would it look like to call "v.db.dropcolumn" using pygrass? Thank you for your help :) – Camille Morlus Jan 14 '21 at 20:33r.in_gdal(input=input_map , output=current_date+'_qa' , memory=max_memory, overwrite=True),v.proj(location='Paraguay_hydrography' , mapset=mapset , input=paraguay_hydrography_shp_name, overwrite=True),v.extract(input='gis_osm_water_a_free_1' , where="name = 'Lago Ypacaraí'", output='ypacarai_lake', overwrite=True)– F.H. Jan 14 '21 at 20:44