gpt4 book ai didi

python - Heroku 忽略 runtime.txt 文件

转载 作者:行者123 更新时间:2023-12-05 04:53:34 27 4
gpt4 key购买 nike

我的 Flask 应用程序在本地运行。

当我通过 git push heroku master 将其推送到 Heroku 时,出现以下错误:

 ERROR: Could not find a version that satisfies the requirement numpy==1.20.0 (from -r /tmp/build_b6c59d74/requirements.txt (line 12))

我认为这是因为我本地的 python 版本与 Heroku 的版本不匹配。

当我运行 python -V 时,我得到了 Python 3.7.4

根据下面的完整日志,Heroku 使用当前默认的 python-3.6.12

根据 this article , 我在我的根目录中添加了一个 runtime.txt 文件(与我的 requirements.txt 文件相同的目录)。

我最初添加了 python-3.7.4,但是在检查了 Heroku 的 supported runtimes 之后,看来我应该使用 python-3.7.9

我已经将它更新为 python-3.7.9

当我运行 cat runtime.txt 时,我得到 python-3.7.9

我检查过没有换行符和空格,并且我使用的破折号是正确的。

但是当我运行 git push Heroku master 时,它似乎忽略了 runtime.txt 并安装了 python-3.6.12(参见完整日志如下)。

我检查过我正在运行 supported stack ,当我运行 heroku stack 时,它显示 heroku-20

heroku buildpacks 返回 `heroku/python/。

下面是我运行 git push heroku master 时返回错误的完整日志

Total 0 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Python app detected
remote: -----> Requirements file has been changed, clearing cached dependencies
remote: -----> Installing python-3.6.12
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting alembic==1.5.3
remote: Downloading alembic-1.5.3.tar.gz (1.1 MB)
remote: Collecting click==7.1.2
remote: Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
remote: Collecting Flask==1.1.2
remote: Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
remote: Collecting Flask-Migrate==2.6.0
remote: Downloading Flask_Migrate-2.6.0-py2.py3-none-any.whl (13 kB)
remote: Collecting Flask-SQLAlchemy==2.4.4
remote: Downloading Flask_SQLAlchemy-2.4.4-py2.py3-none-any.whl (17 kB)
remote: Collecting Flask-WTF==0.14.3
remote: Downloading Flask_WTF-0.14.3-py2.py3-none-any.whl (13 kB)
remote: Collecting gunicorn==20.0.4
remote: Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote: Collecting itsdangerous==1.1.0
remote: Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
remote: Collecting Jinja2==2.11.2
remote: Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
remote: Collecting Mako==1.1.4
remote: Downloading Mako-1.1.4.tar.gz (479 kB)
remote: Collecting MarkupSafe==1.1.1
remote: Downloading MarkupSafe-1.1.1-cp36-cp36m-manylinux2010_x86_64.whl (32 kB)
remote: ERROR: Could not find a version that satisfies the requirement numpy==1.20.0 (from -r /tmp/build_b6c59d74/requirements.txt (line 12)) (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0b3, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.11.1rc1, 1.11.1, 1.11.2rc1, 1.11.2, 1.11.3, 1.12.0b1, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.1rc1, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3, 1.14.0rc1, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0rc1, 1.15.0rc2, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0rc1, 1.16.0rc2, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0rc1, 1.17.0rc2, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0rc1, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0rc1, 1.19.0rc2, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5)
remote: ERROR: No matching distribution found for numpy==1.20.0 (from -r /tmp/build_b6c59d74/requirements.txt (line 12))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: dd64a89ce1402daf7c7b0804558f3f6ec776d188
remote: !
remote: ! We have detected that you have triggered a build from source code with version dd64a89ce1402daf7c7b0804558f3f6ec776d188
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...
remote:
remote: ! Push rejected to pure-lowlands-59273.
remote:
To https://git.heroku.com/pure-lowlands-59273.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-lowlands-59273.git'

请注意,我认为上面的警告是无关的,而是因为我多次尝试推送到 Heroku。

我检查了https://devcenter.heroku.com/articles/duplicate-build-version这似乎不是问题。所有本地更改均已提交且分支正确(均在 master 分支上)。

这个看似简单的过程真的让我怀疑自己的理智。

我在网上找不到以上报告类似错误的人,所以我假设这是某种打字错误?

我检查了 17 次 runtime.txt 的拼写及其文件内容是否有额外的空格或换行符。没有骰子。

我希望得到一些帮助。非常感谢您的帮助!

最佳答案

所以我想出了问题所在。

在我的 requirements.txt 文件中更新 numpy==1.19.5 后,尝试下载 numpy==1.20 时返回相同的错误.0

此时,Mihai’s评论看起来很有可能——这是一个提交问题。

我重读了https://devcenter.heroku.com/articles/duplicate-build-version并注意到以下通知:

Following changes in the industry, Heroku has updated our default git branch name to main. If the project you’re deploying uses master as its default branch name, use git push heroku master.

我注意到我在笔记中使用 git push heroku master 作为将更改部署到 Heroku 的方式。所以也许在此过程中的某个地方,我用 git 做了一些时髦的事情并推到了错误的分支。

我找到了这篇文章 https://devcenter.heroku.com/articles/git-branches关于从 Master -> Main 迁移。

所以我跑了:

git checkout master
git checkout -b main
git push heroku main

Bang... 直接进入 python-3.7.9

谢谢大家的帮助!

我希望这个解释能阻止其他人在未来犯同样的错误:)

关于python - Heroku 忽略 runtime.txt 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65986913/

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