Re: [GRASS-user] Can't use simple GRASS modules in python when not using ".py" in module call
Dear Stefan, The GRASS version is 8.4.1. and the simple commands I used are the ones in my previous email. You helped me solve the problem; I had not added the addons and "C:\Program Files\GRASS GIS 7.8\scripts" into the PATH variable. Now I did and it solved the mistake. Thank you very much! Cheers, Camille Le ven. 15 janv. 2021 à 15:08, Stefan Blumentrath < stefan.blumentr...@nina.no> a écrit : > Dear Camille, > > > > I don`t get that error in GRASS 7.8.3 with your example. > > > > Can you post the exact command (if it was different from your example), > and GRASS version as well as OS? > > Addons need to be on your PATH / ADDON_PATH. > > > > Cheers > > Stefan > > > > > > *From:* grass-user *On Behalf Of *Cam > Morlus > *Sent:* fredag 15. januar 2021 11:37 > *To:* grass-user@lists.osgeo.org > *Subject:* [GRASS-user] Can't use simple GRASS modules in python when not > using ".py" in module call > > > > Dear All, > > > 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 > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fv.db.dropcolumn.py%2F=04%7C01%7C%7C6777bf389f194dc3954a08d8b941928a%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637463038877120044%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=ra6Nu%2FwP%2BDmHIPxzKtlzwo%2FzLJuve01OwcqqXQweW7k%3D=0>", > 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. I tried to use pygrass and it also raises an error if I'm using > Module("v.db.dropcolumn") instead of Module("v.db.dropcolumn.py > <https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fv.db.dropcolumn.py%2F=04%7C01%7C%7C6777bf389f194dc3954a08d8b941928a%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637463038877120044%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=ra6Nu%2FwP%2BDmHIPxzKtlzwo%2FzLJuve01OwcqqXQweW7k%3D=0> > "). > > > > Does anybody know how to solve this? > > > > Thank you in advance for the answer, > > > > Best, > > > > Camille Morlighem > ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Can't use simple GRASS modules in python when not using ".py" in module call
Dear Camille, I don`t get that error in GRASS 7.8.3 with your example. Can you post the exact command (if it was different from your example), and GRASS version as well as OS? Addons need to be on your PATH / ADDON_PATH. Cheers Stefan From: grass-user On Behalf Of Cam Morlus Sent: fredag 15. januar 2021 11:37 To: grass-user@lists.osgeo.org Subject: [GRASS-user] Can't use simple GRASS modules in python when not using ".py" in module call Dear All, 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<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fv.db.dropcolumn.py%2F=04%7C01%7C%7C6777bf389f194dc3954a08d8b941928a%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637463038877120044%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=ra6Nu%2FwP%2BDmHIPxzKtlzwo%2FzLJuve01OwcqqXQweW7k%3D=0>", 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. I tried to use pygrass and it also raises an error if I'm using Module("v.db.dropcolumn") instead of Module("v.db.dropcolumn.py<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fv.db.dropcolumn.py%2F=04%7C01%7C%7C6777bf389f194dc3954a08d8b941928a%7C6cef373021314901831055b3abf02c73%7C0%7C0%7C637463038877120044%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=ra6Nu%2FwP%2BDmHIPxzKtlzwo%2FzLJuve01OwcqqXQweW7k%3D=0>"). Does anybody know how to solve this? Thank you in advance for the answer, Best, Camille Morlighem ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Can't use simple GRASS modules in python when not using ".py" in module call
Dear All, 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. I tried to use pygrass and it also raises an error if I'm using Module("v.db.dropcolumn") instead of Module("v.db.dropcolumn.py"). Does anybody know how to solve this? Thank you in advance for the answer, Best, Camille Morlighem ___ grass-user mailing list grass-user@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-user