sentinel-hub/field-delineation

libpq.so.5: cannot open shared object file: No such file or directory

Closed this issue · 2 comments

I'm trying to run the notebook.

After installing all the dependencies, when running the second cell
first, it was raising that the fd module could not be found. But I "solved" it with the lines below

import sys
sys.path.append("..")

Now, I'm getting this error: libpq.so.5: cannot open shared object file: No such file or directory.

It is raised when this line is reached: from fd.scripts.vector_to_raster import rasterise_gsaa

Here is the complete error raised in the notebook:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[5], line 21
     19 from fd.scripts.download import batch_download
     20 from fd.scripts.tiffs_to_eopatches import convert_tiff_to_eopatches
---> 21 from fd.scripts.vector_to_raster import rasterise_gsaa
     22 from fd.scripts.sampling import sample_patchlets
     23 from fd.scripts.patchlets_to_npz import patchlets_to_npz_files

File ~/SageMaker/field-delineation/notebooks/../fd/scripts/vector_to_raster.py:25
     21 from sentinelhub import CRS
     23 from eolearn.core import FeatureType, EOExecutor
---> 25 from fd.gsaa_to_eopatch import GsaaToEopatchConfig, get_gsaa_to_eopatch_workflow
     26 from fd.utils import LogFileFilter
     29 stdout_handler = logging.StreamHandler(sys.stdout)

File ~/SageMaker/field-delineation/notebooks/../fd/gsaa_to_eopatch.py:18
     15 import pyproj
     16 from shapely.ops import transform
---> 18 import psycopg2
     20 import geopandas as gpd
     22 import numpy as np

File ~/anaconda3/envs/fdenv/lib/python3.9/site-packages/psycopg2/__init__.py:51
      1 """A Python driver for PostgreSQL
      2 
      3 psycopg is a PostgreSQL_ database adapter for the Python_ programming
   (...)
     17     TimeFromTicks, Timestamp, TimestampFromTicks
     18 """
     19 # psycopg/__init__.py - initialization of the psycopg module
     20 #
     21 # Copyright (C) 2003-2019 Federico Di Gregorio  <fog@debian.org>
   (...)
     48 
     49 # Import the DBAPI-2.0 stuff into top-level module.
---> 51 from psycopg2._psycopg import (                     # noqa
     52     BINARY, NUMBER, STRING, DATETIME, ROWID,
     53 
     54     Binary, Date, Time, Timestamp,
     55     DateFromTicks, TimeFromTicks, TimestampFromTicks,
     56 
     57     Error, Warning, DataError, DatabaseError, ProgrammingError, IntegrityError,
     58     InterfaceError, InternalError, NotSupportedError, OperationalError,
     59 
     60     _connect, apilevel, threadsafety, paramstyle,
     61     __version__, __libpq_version__,
     62 )
     65 # Register default adapters.
     67 from psycopg2 import extensions as _ext

ImportError: libpq.so.5: cannot open shared object file: No such file or directory

Let me know what to do to solve this problem.
Thanks!

batic commented

HI @tiago-lam

The vector_to_raster part of the workflow relies on PostgreSQL. I believe your error comes from (bad) installation of the psycopg2. Please have a look if you have it installed properly (e.g. all the necessary libraries are there as well).

Perhaps have a look at psycopg2 issues/forums, e.g. psycopg/psycopg2#892

Hi @batic
Yes, installing psycopg manually with pip did it for me.
Thanks!