[GRASS-user] Error import from grass.pygrass.vector library

Manuele Pesenti manuele.pesenti at gter.it
Fri Aug 20 07:40:22 PDT 2021


Dear All,

 

I'm moving my first steps on the development of a python script that uses Grass, but I cannot import from the grass.pygrass.vector library. 

I work on a Ubuntu/Linux environment and I've installed grass using apt, this is the test script I'm currently running: 



# -*- coding: utf-8 -*-



import os, sys



GISBASE = '/usr/lib/grass78'

GRASSBIN = '/usr/bin/grass78'



# Define GRASS-Python environment

os.environ['GISBASE'] = GISBASE



os.environ['GRASSBIN'] = GRASSBIN



sys.path.append(os.path.join(GISBASE, "etc", "python"))



from grass_session import Session

import grass.script as gs



print(f"LD_LIBRARY_PATH: {os.environ['LD_LIBRARY_PATH']}")

print(f"GRASSBIN: {os.environ['GRASSBIN']}")



from grass.pygrass.vector import Vector



print('DONE!')



and this is the output:



$ python import_test.py 

LD_LIBRARY_PATH: /usr/lib/grass78/lib

GRASSBIN: /usr/bin/grass78

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.9/ctypes/__init__.py", line 452, in LoadLibrary

    return self._dlltype(name)

  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, 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 "/home/manuele/Lavoro/ETS/ETSCore/scripts/import_test.py", line 21, in <module>

    from grass.pygrass.vector import Vector

  File "/usr/lib/grass78/etc/python/grass/pygrass/vector/__init__.py", line 5, 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




Thank you very mutch for any help



Cheers



      Manuele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20210820/a0013c06/attachment.html>


More information about the grass-user mailing list