Flask 为什么部署到heroku时出错?

Flask 为什么部署到heroku时出错?,flask,heroku,Flask,Heroku,我正在尝试将我的应用程序推送到heroku,我正在按照udemy的教程进行操作-正如所解释的,一切都很顺利。一旦我在最后一步-执行git push heroku master时,控制台中会出现以下错误: (flaskdeploy) C:\Users\dmitr\Desktop\jose\FLASK_heroku>git push heroku master Enumerating objects: 5, done. Counting objects: 100% (5/5), done. D

我正在尝试将我的应用程序推送到heroku,我正在按照udemy的教程进行操作-正如所解释的,一切都很顺利。一旦我在最后一步-执行
git push heroku master
时,控制台中会出现以下错误:

(flaskdeploy) C:\Users\dmitr\Desktop\jose\FLASK_heroku>git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
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 mitya-test-app.
remote:
To https://git.heroku.com/mitya-test-app.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mitya-test-app.git'
在my requirements.txt中,我有以下内容:

certifi==2020.12.5
click @ file:///home/linux1/recipes/ci/click_1610990599742/work
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
gunicorn==20.0.4
itsdangerous @ file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe @ file:///C:/ci/markupsafe_1607027406824/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work
wincertstore==0.2
实际上,这只是一个超级简单的测试应用程序,由
app.py
组成:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "THE SITE IS OK"    

if __name__ == '__main__':
    app.run()
Procfile
,其中包含以下内容:

web: gunicorn app:app

我认为问题出在requirement.txt中

除去

click @ file:///home/linux1/recipes/ci/click_1610990599742/work
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
itsdangerous @ file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe @ file:///C:/ci/markupsafe_1607027406824/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work
并替换为

Flask==1.1.2

因为heroku找不到这些包。heroku将从pypi中提取requiremts.txt中的包

我认为问题出在requirement.txt中

除去

click @ file:///home/linux1/recipes/ci/click_1610990599742/work
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
itsdangerous @ file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe @ file:///C:/ci/markupsafe_1607027406824/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work
并替换为

Flask==1.1.2

因为heroku找不到这些包。heroku将从pypi中提取requiremts.txt中的包。我在requirements.txt中看到一个windows路径。不确定您试图在那里做什么,但是您是否有任何理由从本地源安装软件包

所以,我相信从

错误:由于环境原因,无法安装程序包错误:[Errno 2]没有此类文件或目录:'/home/linux1/recipes/ci/click_1610990599742/work

表示pip尝试从不存在的目录安装。您的heroku dyno(容器)尝试获取必要的依赖项,但在构建时失败。如果您不熟悉container,那么本质上它是一个独立的裸骨系统,将从头开始构建,因此需要安装它们(单击、烧瓶等)

tl;drheroku希望从本地安装,失败。尝试更改
requirements.txt
例如

certifi==2020.12.5
click
Flask
gunicorn==20.0.4
itsdangerous
Jinja2
MarkupSafe
Werkzeug
wincertstore==0.2

强制
pip
从外部源(即pypi)安装。

我在您的requirements.txt中看到一个windows路径。不确定您试图在那里做什么,但是您是否有任何理由从本地源安装软件包

所以,我相信从

错误:由于环境原因,无法安装程序包错误:[Errno 2]没有此类文件或目录:'/home/linux1/recipes/ci/click_1610990599742/work

表示pip尝试从不存在的目录安装。您的heroku dyno(容器)尝试获取必要的依赖项,但在构建时失败。如果您不熟悉container,那么本质上它是一个独立的裸骨系统,将从头开始构建,因此需要安装它们(单击、烧瓶等)

tl;drheroku希望从本地安装,失败。尝试更改
requirements.txt
例如

certifi==2020.12.5
click
Flask
gunicorn==20.0.4
itsdangerous
Jinja2
MarkupSafe
Werkzeug
wincertstore==0.2

强制从外部源(即pypi)安装
pip

谢谢,现在一切正常。不用担心,别忘了关注requirements.txt上的依赖版本:)谢谢,现在一切正常。不用担心,别忘了关注requirements.txt上的依赖版本:)