将应用程序推送到 heroku 时出现错误 No such file or directory: 'gdal-config'

Error No such file or directory: 'gdal-config' when pushing app to heroku

我尝试将包含 geopandas 的应用程序推送到 heroku,但出现此错误:

remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> Installing python-3.9.4
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting Fiona==1.8.13.post1
remote:          Downloading Fiona-1.8.13.post1.tar.gz (1.2 MB)
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uxcfxwz1/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uxcfxwz1/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-flgcbl6w
remote:                 cwd: /tmp/pip-install-uxcfxwz1/fiona/
remote:            Complete output (2 lines):
remote:            Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config'
remote:            A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed

我在 this heroku post 中看到您应该添加 heroku 的地理构建包。但是如果我这样做,就像我的应用程序 requirements.txt 不再安装一样。

这是我在添加 heroku 的地理构建包并删除 BUILD_WITH_GEO_LIBRARIES 之后得到的结果,就像 post 说的那样:

remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://github.com/heroku/heroku-geo-buildpack.git
remote: -----> Geo Packages (GDAL/GEOS/PROJ) app detected
remote: -----> Installing GDAL-2.4.0
remote: -----> Installing GEOS-3.7.2
remote: -----> Installing PROJ-5.2.0
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 36.6M
remote: -----> Launching...
remote:        Released v5
remote:        https://rental-properties.herokuapp.com/ deployed to Heroku
remote:
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: d00d76ab85b1646d03d3adcc4e99b759cfbf4f5c
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version d00d76ab85b1646d03d3adcc4e99b759cfbf4f5c
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy... done.

他不再安装 pip 要求了。谁能帮我解决这个问题?

根据你的标签,我假设你正在使用 python。如果是,则您缺少 python 构建包。在你的 gitbash 或 cmd 上做:

heroku buildpacks:set heroku/python