当我在过去几天尝试部署 Django 应用程序时,Heroku Build 返回此错误。 Django代码和文件结构与Django官方文档相同,在根目录下增加了Procfile。
日志 -
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> No Python version was specified. Using the buildpack default: python-3.10.4
To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
Building wheels for collected packages: backports.zoneinfo
Building wheel for backports.zoneinfo (pyproject.toml): started
Building wheel for backports.zoneinfo (pyproject.toml): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python /app/.heroku/python/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpqqu_1qow
cwd: /tmp/pip-install-txfn1ua9/backports-zoneinfo_a462ef61051d49e7bf54e715f78a34f1
Complete output (41 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/backports
copying src/backports/__init__.py -> build/lib.linux-x86_64-3.10/backports
creating build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/_common.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/_version.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/__init__.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
running egg_info
writing src/backports.zoneinfo.egg-info/PKG-INFO
writing dependency_links to src/backports.zoneinfo.egg-info/dependency_links.txt
writing requirements to src/backports.zoneinfo.egg-info/requires.txt
writing top-level names to src/backports.zoneinfo.egg-info/top_level.txt
reading manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.svg' under directory 'docs'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_output'
adding license file 'LICENSE'
adding license file 'licenses/LICENSE_APACHE'
writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
copying src/backports/zoneinfo/__init__.pyi -> build/lib.linux-x86_64-3.10/backports/zoneinfo
copying src/backports/zoneinfo/py.typed -> build/lib.linux-x86_64-3.10/backports/zoneinfo
running build_ext
building 'backports.zoneinfo._czoneinfo' extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/lib
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/app/.heroku/python/include/python3.10 -c lib/zoneinfo_module.c -o build/temp.linux-x86_64-3.10/lib/zoneinfo_module.o -std=c99
lib/zoneinfo_module.c: In function ‘zoneinfo_fromutc’:
lib/zoneinfo_module.c:600:19: error: ‘_PyLong_One’ undeclared (first use in this function); did you mean ‘_PyLong_New’?
600 | one = _PyLong_One;
| ^~~~~~~~~~~
| _PyLong_New
lib/zoneinfo_module.c:600:19: note: each undeclared identifier is reported only once for each function it appears in
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for backports.zoneinfo
Failed to build backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects
! Push rejected, failed to compile Python app.
! Push failed
谢谢。
原文由 SarveshJoshi 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在 heroku 上部署我的应用程序时遇到了同样的错误,问题实际上是当你在 heroku 上部署它时,heroku 默认使用 python 版本 3.10.x 并且 backports.zoneinfo 在这个版本上不能正常工作所以我建议你切换到版本 3.8.x(稳定)。
为此,您需要告诉 heroku 切换该版本,可以按如下方式完成:
PS:为我工作,后来当 heroku 删除这个错误时,你可以切换到 python 最新版本。