首页 > 解决方案 > GDAL 不会安装到 GitHub Actions Ubuntu venv

问题描述

我的 .yml 代码如下所示,用于测试为 Git 上的存储库创建的每个拉取请求。

  name: Python Linux application
  
  on:
    pull_request:
      branches: [ '**' ]
  
  jobs:
    build:
  
      runs-on: ubuntu-latest
  
      steps:
        - uses: actions/checkout@v2
        - name: Set up Python 3.9
          uses: actions/setup-python@v2
          with:
            python-version: 3.9
        - name: Install dependencies
          run: |
            python -m pip install --upgrade pip
            sudo apt-get install libproj-dev proj-data proj-bin
            sudo apt-get install libgeos-dev
            sudo apt-get install gdal-bin libgdal-dev libgdal-doc
            pip install wheel
            pip install flake8 pytest Cython numpy proj geos GDAL==3.2.3
            if [ -f requirements-linux.txt ]; then pip install -r requirements-linux.txt; fi
        - name: Lint with flake8
          run: |
            # stop the build if there are Python syntax errors or undefined names
            flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
            # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
            flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
        - name: Test with pytest
          run: |
            pytest

经过数千 (11390) 行错误代码后,这是最终错误:

error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/hostedtoolcache/Python/3.9.5/x64/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rkrb3fqi/gdal_c6b10766da894ef6b4738e8ab6e2acd7/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rkrb3fqi/gdal_c6b10766da894ef6b4738e8ab6e2acd7/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'"'"'))' install --record /tmp/pip-record-9qjem06l/install-record.txt --single-version-externally-managed --compile --install-headers /opt/hostedtoolcache/Python/3.9.5/x64/include/python3.9/GDAL Check the logs for full command output.

我已经尝试安装所有我能找到的与 GDAL 相关的标头,但似乎没有任何效果。

标签: ubuntugithubpipgdal

解决方案


修复了它,对于那些处于类似情况的人来说,这是这个问题的答案:

      sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
      sudo apt-get update
      sudo apt-get install gdal-bin libgdal-dev
      pip install GDAL==3.2.3

推荐阅读