I've a problem when creating extension postgis, in postgresql and Docker. I've read many post and tutorials, but I've failed :) I'm working on WSL :
# uname -a
Linux 6019b3c71dfc 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 GNU/Linux
# psql -U user -d database -h db
psql (11.14 (Debian 11.14-0 deb10u1), server 10.18)
Type "help" for help.
massifs=# CREATE EXTENSION postgis;
ERROR: could not open extension control file "/usr/local/share/postgresql/extension/postgis.control": No such file or directory
So, I find the postgis.control file :
# find /usr -name postgis.control
/usr/share/postgresql/11/extension/postgis.control
And copy it (and change permissions if needed) in the right folder : cp /usr/share/postgresql/11/extension/postgis.control /usr/local/share/postgresql/extension
But the error is the same :(
I've installed all the libs required :
# dpkg -l | grep postgis
ii postgis 2.5.1 dfsg-1 amd64 Geographic objects support for PostgreSQL
ii postgis-doc 2.5.1 dfsg-1 all Geographic objects support for PostgreSQL -- documentation
ii postgis-gui 2.5.1 dfsg-1 amd64 Geographic objects support for PostgreSQL -- GUI programs
ii postgresql-11-postgis-2.5 2.5.1 dfsg-1 amd64 Geographic objects support for PostgreSQL 11
ii postgresql-11-postgis-2.5-scripts 2.5.1 dfsg-1 all Geographic objects support for PostgreSQL 11 -- SQL scripts
Same error :(
Have you an idea please ?
CodePudding user response:
Note that you are connecting to the wrong server or have a server of a wrong version:
psql (11.14 (Debian 11.14-0 deb10u1), server 10.18)
reports a server version of 10 (10.18) which is definitly not installed by the package postgresql-11-postgis-2.5 (that is for version 11).
I assume you are connecting to a different machine/container (not localhost) that does not have the correct packages installed.
CodePudding user response:
Here's my Dockerfile :
# ./myproject/Dockerfile
FROM python:3.8.6-buster
# set work directory
WORKDIR /opt/myproject
# set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# install dependencies
RUN pip install --upgrade pip
RUN pip install pgcli
COPY ./requirements.txt /opt/myproject/requirements.txt
RUN chmod x /opt/myproject/requirements.txt
RUN pip install -r requirements.txt
# copy project
COPY . /opt/myproject/
# POSTGRESQL
# First RUN Statement: to install postgresql dependency
RUN apt update -y && apt upgrade -y && apt install -y libpq-dev gcc postgresql-client && apt install -y vim vim-common && apt install -y pgcli
# code coverage
RUN pip install coverage
# Third RUN Statement: Remove the gcc compier after install the driver
RUN apt-get autoremove -y gcc
# set timezone
RUN apt install tzdata
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# install GEOS & GDAL
RUN apt install libgeos-dev -y
# install GDAL
RUN apt install -y postgis* libgdal-dev python3-gdal gdal-bin
RUN chmod x /opt/myproject/docker-entrypoint.sh
ENTRYPOINT [ "/opt/myproject/docker-entrypoint.sh"]
CodePudding user response:
I've been using postgis/docker-postgis for if you want to check how they are doing it the Dockerfile is a good place
