[GRASS-user] can't install and execute python script

Hello,

I’ve installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :

Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)…
Compiling…
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.surround: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.intervisibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.area: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.cone: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.competition: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.horizontal.visibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.terrain.vertical.angle: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.terrain.horizon: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.pit2hwtg: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.overhang: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.visibility.what: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.series: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.surround: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/g.wtg.listfromtable: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.drawline: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.transect: not found
Installing…
Updating private addons metadata file…
WARNING: No addons metadata available. Addons metadata file not updated.
Installation of <r.wtg> successfully finished

All files are well copied in /home/me/.grass7/addons/scripts

And when i want to execute one of them (here r.wtg.visibility), I get :

Traceback (most recent call last):
File “/usr/lib/grass78/etc/python/grass/script/task.py”,
line 473, in get_interface_description

p = Popen([cmd, ‘–interface-description’], stdout=PIPE,
File “/usr/lib/grass78/etc/python/grass/script/core.py”,
line 63, in init

subprocess.Popen.init(self, args, **kwargs)
File “/usr/lib/python3.8/subprocess.py”, line 854, in
init

self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.8/subprocess.py”, line 1702, in
_execute_child

raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError
:
[Errno 2] No such file or directory: ‘r.wtg.visibility’
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
File “/usr/lib/grass78/gui/wxpython/gui_core/prompt.py”,
line 272, in OnItemSelected

self.cmdDesc = gtask.parse_interface(cmd)
File “/usr/lib/grass78/etc/python/grass/script/task.py”,
line 522, in parse_interface

tree = etree.fromstring(get_interface_description(name))
File “/usr/lib/grass78/etc/python/grass/script/task.py”,
line 501, in get_interface_description

raise ScriptError(_(“Unable to fetch interface description
for command ‘<{cmd}>’.”
grass.exceptions
.
ScriptError
:
Unable to fetch interface description for command
‘<r.wtg.visibility>’.
Details: <[Errno 2] No such file or directory:
‘r.wtg.visibility’>

If i rename a script with .py, I can execute it from the menu File>execute script

I have two other Grass (7.9) on Debian Buster and it works fine…

The $GRASS_ADDON_BASE = /home/me/.grass7/addons
The $GRASS_ADDON_PATH = /home/me/.grass7/addons/scripts

Do you have any idea that problem ?

Thank you for your help.

···

Frank David

Hi,

On Mon, Mar 15, 2021 at 11:07 AM Frank David <frank.david@geophom.fr> wrote:

Hello,

I've installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :

Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.surround: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.intervisibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.area: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.cone: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visual.competition: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.horizontal.visibility: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.terrain.vertical.angle: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.terrain.horizon: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.pit2hwtg: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.overhang: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.visibility.what: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.series: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.surround: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/g.wtg.listfromtable: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.drawline: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/v.wtg.transect: not found
Installing...
Updating private addons metadata file...
WARNING: No addons metadata available. Addons metadata file not updated.
Installation of <r.wtg> successfully finished

All files are well copied in /home/me/.grass7/addons/scripts

And when i want to execute one of them (here r.wtg.visibility), I get :

Traceback (most recent call last):
  File "/usr/lib/grass78/etc/python/grass/script/task.py",
line 473, in get_interface_description

p = Popen([cmd, '--interface-description'], stdout=PIPE,
  File "/usr/lib/grass78/etc/python/grass/script/core.py",
line 63, in __init__

subprocess.Popen.__init__(self, args, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 854, in
__init__

self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in
_execute_child

raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError
:
[Errno 2] No such file or directory: 'r.wtg.visibility'
During handling of the above exception, another exception
occurred:
Traceback (most recent call last):
  File "/usr/lib/grass78/gui/wxpython/gui_core/prompt.py",
line 272, in OnItemSelected

self.cmdDesc = gtask.parse_interface(cmd)
  File "/usr/lib/grass78/etc/python/grass/script/task.py",
line 522, in parse_interface

tree = etree.fromstring(get_interface_description(name))
  File "/usr/lib/grass78/etc/python/grass/script/task.py",
line 501, in get_interface_description

raise ScriptError(_("Unable to fetch interface description
for command '<{cmd}>'."
grass.exceptions
.
ScriptError
:
Unable to fetch interface description for command
'<r.wtg.visibility>'.
Details: <[Errno 2] No such file or directory:
'r.wtg.visibility'>

If i rename a script with .py, I can execute it from the menu File>execute script

I have two other Grass (7.9) on Debian Buster and it works fine...

The $GRASS_ADDON_BASE = /home/me/.grass7/addons
The $GRASS_ADDON_PATH = /home/me/.grass7/addons/scripts

Do you have any idea that problem ?

This is somehow hard to say - is the addon available for testing?

Markus

Hi,

On Mon, Mar 15, 2021 at 11:31 PM Markus Neteler <neteler@osgeo.org> wrote:

On Mon, Mar 15, 2021 at 11:07 AM Frank David <frank.david@geophom.fr> wrote:
>
> Hello,
>
> I've installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :
>
> Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
> Compiling...
> /bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
> /bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found

...

> Do you have any idea that problem ?

This is somehow hard to say - is the addon available for testing?

For posterity:

I received the addon offlist. Some files showed Python 3 syntax
errors, fixed with "autopep8" and now the installation works (for me).

cheers,
Markus

--
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog

Hi Markus,

Thank you for your reply and correction. But no thing has changed on my Grass 7.8.3 / Ubuntu 20.10, and it’s still working on may Grass 7.69 / Debian Buster (see console below)

(Tue Mar 16 14:50:05 2021)
g.extension extension=r.wtg url=/media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg
Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)…
Compiling…
Installing…
Updating extensions metadata file…
Updating extension modules metadata file…
WARNING: No metadata available for module ‘r.wtg’.
WARNING: No metadata available for module ‘r.wtg’.
Installation of <r.wtg> successfully finished
(Tue Mar 16 14:50:14 2021) La commande s’est terminée (9 sec)

It’s curious that Grass say “…not found” on every script, while copying the file in addons/ ?

···

Frank DAVID

Le 16/03/2021 à 13:24, Markus Neteler a écrit :

Hi,

On Mon, Mar 15, 2021 at 11:31 PM Markus Neteler [<neteler@osgeo.org>](mailto:neteler@osgeo.org) wrote:

On Mon, Mar 15, 2021 at 11:07 AM Frank David [<frank.david@geophom.fr>](mailto:frank.david@geophom.fr) wrote:

Hello,

I've installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :

Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found

...

Do you have any idea that problem ?

This is somehow hard to say - is the addon available for testing?

For posterity:

I received the addon offlist. Some files showed Python 3 syntax
errors, fixed with "autopep8" and now the installation works (for me).

cheers,
Markus

On Tue, Mar 16, 2021 at 3:02 PM Frank David <frank.david@geophom.fr> wrote:

Hi Markus,

Thank you for your reply and correction. But no thing has changed on my Grass 7.8.3 / Ubuntu 20.10, and it's still working on may Grass 7.69 / Debian Buster (see console below)

Yes:

- GRASS GIS 7.6 uses Python 2
- GRASS GIS 7.8 uses Python 3

(Tue Mar 16 14:50:05 2021)
g.extension extension=r.wtg url=/media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg
Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
Installing...
Updating extensions metadata file...
Updating extension modules metadata file...
WARNING: No metadata available for module 'r.wtg'.
WARNING: No metadata available for module 'r.wtg'.
Installation of <r.wtg> successfully finished
(Tue Mar 16 14:50:14 2021) La commande s'est terminée (9 sec)

It's curious that Grass say "...not found" on every script, while copying the file in addons/ ?

Here I didn't get that error but mainly the one with the wrong
formatting. The "... not found" might be a secondary error while the
original error message isn't visible (for whatever reason).

Let me suggest that you update all Python script to Python 3 (there is
the "2to3" script as well as "autopep8" and others for that purpose).
Once done, perhaps the errors you get are gone?

Markus

Frank DAVID

Le 16/03/2021 à 13:24, Markus Neteler a écrit :

Hi,

On Mon, Mar 15, 2021 at 11:31 PM Markus Neteler <neteler@osgeo.org> wrote:

On Mon, Mar 15, 2021 at 11:07 AM Frank David <frank.david@geophom.fr> wrote:

Hello,

I've installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :

Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found

...

Do you have any idea that problem ?

This is somehow hard to say - is the addon available for testing?

For posterity:

I received the addon offlist. Some files showed Python 3 syntax
errors, fixed with "autopep8" and now the installation works (for me).

cheers,
Markus

Hi Markus,

···

Le 16/03/2021 à 18:56, Markus Neteler a écrit :

On Tue, Mar 16, 2021 at 3:02 PM Frank David [<frank.david@geophom.fr>](mailto:frank.david@geophom.fr) wrote:

Hi Markus,

Thank you for your reply and correction. But no thing has changed on my Grass 7.8.3 / Ubuntu 20.10, and it's still working on may Grass 7.69 / Debian Buster (see console below)

Yes:

- GRASS GIS 7.6 uses Python 2
- GRASS GIS 7.8 uses Python 3

I wrote 7.69 but it’s 7.9…


(Tue Mar 16 14:50:05 2021)
g.extension extension=r.wtg url=/media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg
Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
Installing...
Updating extensions metadata file...
Updating extension modules metadata file...
WARNING: No metadata available for module 'r.wtg'.
WARNING: No metadata available for module 'r.wtg'.
Installation of <r.wtg> successfully finished
(Tue Mar 16 14:50:14 2021) La commande s'est terminée (9 sec)

It's curious that Grass say "...not found" on every script, while copying the file in addons/ ?

Here I didn't get that error but mainly the one with the wrong
formatting. The "... not found" might be a secondary error while the
original error message isn't visible (for whatever reason).

Let me suggest that you update all Python script to Python 3 (there is
the "2to3" script as well as "autopep8" and others for that purpose).
Once done, perhaps the errors you get are gone?

Ok I will update at least one script, and remove the other for testing (I know I must update all). But I’m surprised because scripts could be executed with File>Launch script…
I wil tell you soon.

Thank you for your help.
Cheers,
Frank

Markus

Frank DAVID

Le 16/03/2021 à 13:24, Markus Neteler a écrit :

Hi,

On Mon, Mar 15, 2021 at 11:31 PM Markus Neteler [<neteler@osgeo.org>](mailto:neteler@osgeo.org) wrote:

On Mon, Mar 15, 2021 at 11:07 AM Frank David [<frank.david@geophom.fr>](mailto:frank.david@geophom.fr) wrote:

Hello,

I've installed GRASS 7.8.3 on Ubuntu 20.10 (groovy) and when I try to install my own python script, the message is :

Fetching <r.wtg> from </media/zephyr/ress/informatique/scripts/grass/scripts/r.wtg> (be patient)...
Compiling...
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.threshold: not found
/bin/sh: 1: /tmp/grass7-geophom-78286/tmp1tw0ncyb/r.wtg/scripts/r.wtg.visibility.conv: not found

...

Do you have any idea that problem ?

This is somehow hard to say - is the addon available for testing?

For posterity:

I received the addon offlist. Some files showed Python 3 syntax
errors, fixed with "autopep8" and now the installation works (for me).

cheers,
Markus