Django,GDAL和CircleCI 2

Anc*_*nia 6 django gdal geodjango docker circleci

我有一个配置有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.
Run Code Online (Sandbox Code Playgroud)

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

除了postgres和GDAL码头工人镜像之外,是否还有其他步骤在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
Run Code Online (Sandbox Code Playgroud)

小智 4

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

apt-get update && apt-get install -y \
gdal-bin python-gdal python3-gdal
Run Code Online (Sandbox Code Playgroud)

就在你跑步的地方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
Run Code Online (Sandbox Code Playgroud)