[GRASS-user] R: exwcuting grass python script from php web page

Markus Neteler neteler at osgeo.org
Sun Oct 4 02:04:38 PDT 2020


Hi Roberta,

On Wed, Sep 30, 2020 at 5:12 PM roberta fagandini
<robifagandini at hotmail.it> wrote:
> On 28/09/20 18:37, roberta fagandini wrote:
> > On 28/09/20 17:51, roberta fagandini wrote:
> >> Sorry, maybe I didn't explain myself well because actually, I don't get
> >> any error from the php web page, simply the code related to grass is not
> >> executed.For instance gsetup.init(gisbase, gisdb, location, mapset) does
> >> not create any file in my /tmp/ folder and the print(gscript.gisenv())
> >> is not printed.
> >> I checked the import of the grass libraries (print(sys.modules)) and
> >> they seem to be correctly imported.
> >
> > Have you checked your webservers error logs ?
> >
> > I have already checked and this is the error in the webserver log file

I observe that:

> > File "importgrass.py", line 82, in <module>
> >      main()
> >    File "importgrass.py", line 71, in main
> >      rcfile = gsetup.init(gisbase, gisdb, location, mapset)
> >    File "/usr/lib/grass74/etc/python/grass/script/setup.py", line 170,

... you use GRASS GIS 7.4? Pretty old and outdated.

> > in init
> >      config_dir = os.path.join(os.getenv('HOME'), config_dirname)
> >    File "/usr/lib/python3.6/posixpath.py", line 80, in join

... you try to use GRASS GIS 7.4 with Python 3. For this you need
GRASS GIS 7.8 as already suggested.

> >      a = os.fspath(a)
> > TypeError: expected str, bytes or os.PathLike object, not NoneType
...
> I tried to upgrade GRASS using the repository ubuntugis unstable but it caused some problems with
> the installation of postgis.

Which problems exactly?

> >         $command = escapeshellcmd('/usr/bin/python3 importgrass.py ');

... Python 3, fine. But here:

> I tried to run '/usr/bin/grass --version' but I got a similar error:
>
> File "/usr/bin/grass", line 2005, in <module>
>     main()
>   File "/usr/bin/grass", line 1804, in main
>     grass_config_dir = get_grass_config_dir()
>   File "/usr/bin/grass", line 398, in get_grass_config_dir
>     directory = os.path.join(os.getenv('HOME'), grass_config_dirname)
>   File "/usr/lib/python2.7/posixpath.py", line 70, in join

... again Python 2.

This mixture will not work. Do you have by chance multiple GRASS GIS
versions installed?

I'd suggest removing all installed GRASS packages and reinstalling 7.8
cleanly again.

best
Markus


More information about the grass-user mailing list