[英]Run Django in docker container with GDAL
我目前正在嘗試在 docker 容器內運行 Django 項目,以為該項目提供本地數據庫。
該項目依賴於 GDAL,但在嘗試安裝要求時,它總是遇到同樣的問題。 以下是我的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 . .
我的 requirements.txt 如下:
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
我收到的錯誤消息總是:
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
我的解決方案已經用完了。
提前謝謝。
我發現了問題。 conda 安裝修復了 GDAL 問題。 但。 安裝 requirements.txt 時,GDAL 被第二次安裝,這導致了錯誤,因為正常的 pip 安裝無法與 GDAL 一起正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.