OSGeo/gdal

error in GDAL setup command: use_2to3 is invalid.

Closed this issue · 1 comments

Expected behavior and actual behavior.

Installing without errors.

Steps to reproduce the problem.

I'm using docker with multistage build:
Here is my Dockerfile:

# Build stage
FROM python:3.9-slim-buster AS build

RUN apt-get update \
  && apt-get install -y gettext \
  && apt-get install -y build-essential \
  && apt-get install -y libpq-dev \
  && apt-get install -y gcc \
  && apt-get install -y libgdal-dev \
  && apt-get install -y libpango-1.0-0 \
  && apt-get install -y libharfbuzz0b \
  && apt-get install -y libpangoft2-1.0-0 \
  && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app
# poetry
RUN pip install poetry
COPY poetry.lock pyproject.toml /
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi

# Production stage
FROM python:3.9-slim-buster
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

ARG UID
ARG GID
RUN groupadd -g $GID -o django \
  && useradd -u $UID -g $GID -o -s /bin/bash -m django
COPY --from=build /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=build /usr/local/bin/poetry /usr/local/bin/poetry
COPY ./_compose/app/scripts/start-django \
  ./_compose/app/scripts/start-celerybeat \
  ./_compose/app/scripts/start-celeryworker /
RUN chmod +x /start-django /start-celerybeat /start-celeryworker
RUN mkdir -p /app/code && chown -R django:django /app
USER django
WORKDIR /app/code

Error when I'm doing docker-compose up:

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

I'm trying to solve it inside container and then replicate in dockerfile because builds are too long.

I've dive into container with:
And doing this tutorial:
https://gis.stackexchange.com/a/74060

docker exec -u 0 -it backend bash

$ apt-get update
$ apt-get install libgdal-dev
$ gdal-config --version
2.4.0
$ pip install GDAL==2.4.0
Collecting GDAL==2.4.0
  Using cached GDAL-2.4.0.tar.gz (564 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      /usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'use_2to3_fixers'
        warnings.warn(msg)
      /usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'use_2to3_exclude_fixers'
        warnings.warn(msg)
      error in GDAL setup command: use_2to3 is invalid.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.

Please help

It might not be GDAL specific (cf https://stackoverflow.com/questions/69100275/error-while-downloading-the-requirements-using-pip-install-setup-command-use-2), and we no longer support GDAL 2.4 which is antiquated now