gpt4 book ai didi

Django、GDAL 和 CircleCI 2

转载 作者:IT老高 更新时间:2023-10-28 21:38:19 25 4
gpt4 key购买 nike

我有一个配置了 GeoDjango 的 Django 应用程序在 CircleCI 2.0 构建中失败并出现以下错误:

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library. Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

但是,当我从 settings.py 中的 DJANGO_APPS 中删除 'django.contrib.gis' 时,构建会成功运行。

除了 postgres 和 GDAL docker 镜像之外,在 CircleCI 中配置 GDAL 是否还有其他步骤?我(可能是错误的)假设在安装 docker 镜像后会找到 GDAL。下面是我的 config.yml:

version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.3

- image: circleci/postgres:10.1-postgis
environment:
- POSTGRES_USER=ubuntu
- POSTGRES_DB=myapp_test

- image: geodata/gdal

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}

- run:
name: run tests
command: |
. venv/bin/activate
python manage.py test
environment:
DATABASE_URL: "postgres://ubuntu@localhost:5432/myapp_test"

- store_artifacts:
path: test-reports
destination: test-reports

最佳答案

我通过添加以下内容来修复它:

apt-get update && apt-get install -y \
gdal-bin python-gdal python3-gdal

就在你运行pip install的地方:

  - run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
apt-get update && apt-get install -y \
gdal-bin python-gdal python3-gdal

关于Django、GDAL 和 CircleCI 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48272384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com