简体   繁体   中英

Run Django in docker container with GDAL

I am currently trying to run a Django project inside a docker container, to provide the project with a local DB.

The Project is depending on GDAL, but when trying to install the requirements it always runs into the same problem. The following is my dockerfile:

RUN apt-get update

RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/*

RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && mkdir /root/.conda \
    && bash Miniconda3-latest-Linux-x86_64.sh -b \
    && rm -f Miniconda3-latest-Linux-x86_64.sh
RUN conda --version

RUN conda create -n gdal_test python=3.9
RUN activate gdal_test
RUN conda install gdal

RUN apt-get update
RUN apt-get -y install gcc

COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt

COPY . .

My requirements.txt is as following:

asgiref==3.3.1
bitstring==3.1.7
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
class-registry==2.1.2
cryptography==3.3.1
decorator==4.4.2
decorators==2.0.7
Django==3.1.5
django-filter==2.4.0
django-mssql==1.8
Django-Verify-Email==0.0.4
djangorestframework==3.12.2
ecdsa==0.16.1
enum34==1.1.10
esptool==3.0
filters==1.3.2
GDAL==3.2.0
idna==2.10
pgxnclient==1.3.1
Pillow==8.1.0
psycopg2-binary==2.8.6
pycparser==2.20
pyserial==3.5
python-dateutil==2.8.1
python-http-client==3.3.1
pytz==2020.5
PyYAML==5.4.1
reedsolo==1.5.4
regex==2020.11.13
requests==2.25.1
self==2020.12.3
sendgrid==6.5.0
six==1.15.0
sqlparse==0.4.1
starkbank-ecdsa==1.1.0
style>=1.1.0
typing==3.7.4.3
update==0.0.1
urllib3==1.26.2

The Error message I get is always:

 Building wheel for GDAL (setup.py): started
#17 35.55   Building wheel for GDAL (setup.py): finished with status 'error'
#17 35.55   ERROR: Command errored out with exit status 1:
#17 35.55    command: /root/miniconda3/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b4fotwdf/gdal_7d28262936544faa8ed19ca69c3b6f2a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b4fotwdf/gdal_7d28262936544faa8ed19ca69c3b6f2a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-sszyhfnn

I am running out of solutions.

Thx in advance.

I found the problem. The conda install fixed the GDAL problem. BUT. When installing requirements.txt, GDAL got installed a second time and this caused the error, since the normal pip install is not working properly with GDAL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM