Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on build: ‘OPTGetProjectionMethods’ was not declared in this scope #2293

Closed
checkplant opened this issue Mar 3, 2020 · 3 comments

Comments

@checkplant
Copy link

Expected behavior and actual behavior.

Im trying to build/install GDAL using pip and im getting this error:

error: OPTGetProjectionMethods was not declared in this scope; did you mean py_OPTGetProjectionMethods

Steps to reproduce the problem.

Here is my docker File:

# Docker container that installs Python 3.6, GDAL and necessary shippable dependencies for CI
FROM python:3.7-stretch

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Update base container install
RUN apt-get update
RUN apt-get upgrade -y

# Add unstable repo to allow us to access latest GDAL builds
RUN echo deb http://ftp.uk.debian.org/debian unstable main contrib non-free >> /etc/apt/sources.list
RUN apt-get update

## Install PostGIS
#RUN apt-get -t unstable install -y postgresql-11-postgis-2.5
#
## Update privs to allow Postgres to run locally
#RUN sed -i "s/local   all             postgres                                peer/local   all             postgres                                trust/" /etc/postgresql/11/main/pg_hba.conf


## Existing binutils causes a dependency conflict, correct version will be installed when GDAL gets intalled
RUN apt-get remove -y binutils
#
## Install GDAL dependencies
RUN apt-get -t unstable install -y libgdal-dev g++
#
## Update C env vars so compiler can find gdal
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
#

## Install CURL certs
RUN apt-get install ca-certificates -y
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

## This will install latest version of GDAL
RUN pip install numpy
RUN pip install GDAL==2.4.4

## Setup default locale
#RUN echo en_US.UTF-8 UTF-8 > /etc/locale.gen
#RUN locale-gen en_US.UTF-8

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Define environment variable
ENV CELERY_BROKER_URL redis://redis:6379/0
ENV CELERY_RESULT_BACKEND redis://redis:6379/0
ENV C_FORCE_ROOT true

ENV FLASK_CONFIG development
ENV FLASK_ENV development
ENV FLASK_APP app/__init__.py

EXPOSE 8000

CMD ["gunicorn", "wsgi:app", "-b", "0.0.0.0:8000", "-w", "4", "--log-level", "debug"]

GDAL version and provenance

2.4.4

@rouault
Copy link
Member

rouault commented Mar 3, 2020

Probably a mismatch between your native GDAL and the python bindings forced at 2.4.4. OPTGetProjectionMethods() has been removed starting with GDAL 3.0, so I presume you got that version as the native lib

@rouault rouault closed this as completed Mar 3, 2020
@checkplant
Copy link
Author

right...do you have any tips on how to fix it?

@tomsaleeba
Copy link

tomsaleeba commented Nov 10, 2020

You can check the version of your native GDAL that you get from your Docker base image:

$ docker run --rm -it --entrypoint bash python:3.7-stretch -c 'apt update && apt show libgdal-dev'
...
Package: libgdal-dev
Version: 2.1.2+dfsg-5
...

You're trying to install python bindings for GDAL 2.4.4, which doesn't match the native version 2.1.2.

You either need to change the version of your python bindings:

# untested
RUN pip install GDAL==2.1.2

...or change Docker base image to one that can provide GDAL 2.4.4. python:3.7-buster provides 2.4.0 which might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants