TransWikia.com

Problem with integration of GRASS-Gis in creating a process for PyWPS

Geographic Information Systems Asked on March 22, 2021

Hey everyone:) It’s possible that I have some kind of miss-conception in my head and just wanted to ask it here. I have a space-time-datacube in GRASS-Gis and now I’d like to create a process in PyWPS that lets me calculate some statistics for an index (e.g. the ndvi).
I do have a script and I can create the process and see it on localhost. However, when I send a request to the server I always get:

PS&identifier=sen2_index&version=1.0.0 HTTP/1.1" 200 -
127.0.0.1 - - [22/Jun/2020 16:58:14] "GET /favicon.ico HTTP/1.1" 404 -
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pywps/app/Process.py", line 236, in _run_process
    self._set_grass(wps_request)
  File "/usr/local/lib/python3.6/dist-packages/pywps/app/Process.py", line 362, in _set_grass
    from grass.script import core as grass
ModuleNotFoundError: No module named 'grass'
127.0.0.1 - - [22/Jun/2020 16:59:10] "GET /wps?request=Execute&service=WPS&identifier=sen2_index&version=1.0.0&datainputs=start=2019-07-01;end=2019-12-01 HTTP/1.1" 200 -

So it apparently doesn’t find Grass. I’d like to give some more information about my installation etc., but I’m really sure how to access these informations. I do have miniconda installed and I always do a conda deactivate prior to start GRASS. At least to start the gui this is for some reason necessary (I think for matching the python-version).

If someone has any comment on what I could do or how to proceed, would be awesome:)

Update

I configured my pywps.cfg and modified the line gisbase=/usr/bin/grass78
to
gisbase=/usr/lib/grass78

What I get now in my console is this here:

 "GET /wps?request=DescribeProcess&service=WPS&identifier=sen2_index&version=1.0.0 HTTP/1.1" 200 -
Traceback (most recent call last):
  File "/usr/lib/grass78/etc/python/grass/lib/ctypes_loader.py", line 76, in load
    return ctypes.cdll.LoadLibrary(path)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libgrass_datetime.7.8.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pywps/app/Process.py", line 236, in _run_process
    self._set_grass(wps_request)
  File "/usr/local/lib/python3.6/dist-packages/pywps/app/Process.py", line 414, in _set_grass
    from grass.pygrass.gis import make_mapset
  File "/usr/lib/grass78/etc/python/grass/pygrass/gis/__init__.py", line 13, in <module>
    import grass.lib.gis as libgis
  File "/usr/lib/grass78/etc/python/grass/lib/gis.py", line 23, in <module>
    _libs["grass_gis.7.8"] = load_library("grass_gis.7.8")
  File "/usr/lib/grass78/etc/python/grass/lib/ctypes_loader.py", line 62, in load_library
    return self.load(path)
  File "/usr/lib/grass78/etc/python/grass/lib/ctypes_loader.py", line 78, in load
    raise ImportError(e)
ImportError: libgrass_datetime.7.8.so: cannot open shared object file: No such file or directory
127.0.0.1 - - [23/Jun/2020 08:24:54] "GET /wps?request=Execute&service=WPS&identifier=sen2_index&version=1.0.0&datainputs=start=2019-07-01;end=2019-12-01 HTTP/1.1" 200 -


2 Answers

It looks like the system does not know the path of your current GRASS installation. Have you checked that you have the GRASSBIN set to your current GRASS version?

You can do that in the commandline (assuming your grass version is 7.8) like:

grass --config path
export GRASSBIN=grass78 

or directly from within your script like

import os
os.system('grass --config path')
os.system('export GRASSBIN=grass78')

Answered by Hasnein Tareque on March 22, 2021

In addition to GRASSBIN, you need to set LD_LIBRARY_PATH with following command.

export LD_LIBRARY_PATH=$(grass --config path)/lib

This will set LD_LIBRARY_PATH variable.

Answered by user50025 on March 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP