-2

when I deploy my project on google cloud I get the error

File "/opt/python3.7/lib/python3.7/ctypes/__init__.py", line 377, in __getattr__
   func = self.__getitem__(name)
File "/opt/python3.7/lib/python3.7/ctypes/__init__.py", line 382, in __getitem__
  func = self._FuncPtr((name_or_ordinal, self))
 AttributeError: /usr/lib/libgdal.so.1: undefined symbol: OGR_F_GetFieldAsInteger64

my Dockerfile

FROM gcr.io/google-appengine/python

  RUN apt-get update && apt-get install -y \
     binutils \
   gdal-bin \
   python-gdal

   # Create a virtualenv for dependencies. This isolates these packages from
   # system-level packages.
   RUN virtualenv /env -p python3.7

   # Setting these environment variables are the same as running
   # source /env/bin/activate.
   ENV VIRTUAL_ENV /env
   ENV PATH /env/bin:$PATH

   # Copy the application's requirements.txt and run pip to install all
   # dependencies into the virtualenv.
   ADD  requirements.txt /app/requirements.txt
   RUN pip install -r /app/requirements.txt
   # Add the application source code.
   ADD . /app

   # Run a WSGI server to serve the application. gunicorn must be declared as
   # a dependency in requirements.txt.
   gunicorn -b :$PORT tiwari.tiwari.wsgi
  • 3
    This was the first hit on my web search for your error: https://stackoverflow.com/questions/59309687/attributeerror-usr-lib-libgdal-so-1-undefined-symbol-ogr-f-getfieldasinteger –  Jul 17 '20 at 16:51

1 Answers1

1

Instead of using the appengine image, try to retrieve the image directly from Python:

FROM python:latest

  RUN apt-get update && apt-get install -y \
     binutils \
   gdal-bin \
   python-gdal

   # Create a virtualenv for dependencies. This isolates these packages from
   # system-level packages.
   RUN virtualenv /env -p python3.7

   # Setting these environment variables are the same as running
   # source /env/bin/activate.
   ENV VIRTUAL_ENV /env
   ENV PATH /env/bin:$PATH

   # Copy the application's requirements.txt and run pip to install all
   # dependencies into the virtualenv.
   ADD  requirements.txt /app/requirements.txt
   RUN pip install -r /app/requirements.txt
   # Add the application source code.
   ADD . /app

   # Run a WSGI server to serve the application. gunicorn must be declared as
   # a dependency in requirements.txt.
   gunicorn -b :$PORT tiwari.tiwari.wsgi
Emmanuel
  • 131
  • 3