【问题标题】:Heroku: Unable to deploy, cannot parse procfileHeroku:无法部署,无法解析 procfile
【发布时间】:2021-08-31 21:47:10
【问题描述】:

这是我的应用程序根目录的样子:

flask-submission-form
 ├ app
 │ ├ templates
 │ │ ├ base.html
 │ │ └ index.html
 │ ├ app.py
 │ ├ extensions.py
 │ └ __init__.py
 ├ assets
 │ └ css
 │ │ ├ custom.css
 │ │ └ main.css
 ├ .env
 ├ .gitignore
 ├ definitions.py
 ├ gulpfile.js
 ├ package-lock.json
 ├ package.json
 ├ postcss.config.js
 ├ Procfile
 ├ README.md
 ├ requirements.txt
 └ tailwind.config.js

app/ 目录如下所示:

app
 ├ templates
 │ ├ base.html
 │ └ index.html
 ├ app.py
 ├ extensions.py
 └ __init__.py

我的__init__.py 包含我的主应用代码,如下所示:

from flask import Flask, request, render_template
import os
from .extensions import register_extensions

def create_app():
    app = Flask(__name__)

    register_extensions(app)

    @app.route("/", methods =["GET", "POST"])
    def index():
        if request.method == "POST":
           #  Do a Bunch of Stuff

我的app.py 看起来像这样:

from app import create_app
app = create_app()

我把这个放在我的Procfile:

web: gunicorn app.app:create_app()

但是当我尝试将其部署到 Heroku 时,我收到以下错误:

remote:  !     Push failed: cannot parse Procfile.
remote:  !     Please try pushing again.
remote:  !     If the problem persists, see https://help.heroku.com/ and provide Request ID 28547bd1-bce5-f7f2-e770-b2cb7b73be26.
remote:
remote:
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: fbbc38150c6a8d344932d53a7c40ae4880c288c8
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version fbbc38150c6a8d344932d53a7c40ae4880c288c8
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !

在给定我的应用程序结构的情况下,如何正确配置我的Procfile,以便正确部署它?如果有帮助,this is my repo

【问题讨论】:

  • 嘿,解码是什么,用utf-8做

标签: python flask heroku deployment


【解决方案1】:

您的应用是从您共享的存储库中完美部署的。如果它仍然存在同样的问题,那么可能是文件编码的问题。 请参阅此问题以供参考 - https://help.heroku.com/CH22EKEK/why-am-i-seeing-push-failed-can-not-parse-procfile-when-deploying-my-app

日志

PS C:\Users\lovekesh\Desktop\npx\submission> git push heroku master
Enumerating objects: 137, done.
Counting objects: 100% (137/137), done.
Delta compression using up to 12 threads
Compressing objects: 100% (62/62), done.
Writing objects: 100% (137/137), 46.62 KiB | 9.32 MiB/s, done.
Total 137 (delta 61), reused 137 (delta 61), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Python,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote:  !     Python has released a security update! Please consider upgrading to python-3.8.10
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.8.8
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 certifi==2021.5.30
remote:          Downloading certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
remote:        Collecting chardet==4.0.0
remote:          Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
remote:        Collecting click==8.0.1
remote:          Downloading click-8.0.1-py3-none-any.whl (97 kB)
remote:        Collecting colorama==0.4.4
remote:          Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
remote:        Collecting contentful==1.13.0
remote:          Downloading contentful-1.13.0.tar.gz (24 kB)
remote:        Collecting contentful-management==2.11.0
remote:          Downloading contentful_management-2.11.0.tar.gz (38 kB)
remote:        Collecting Flask==2.0.1
remote:          Downloading Flask-2.0.1-py3-none-any.whl (94 kB)
remote:        Collecting Flask-Assets==2.0
remote:          Downloading Flask_Assets-2.0-py3-none-any.whl (8.5 kB)
remote:        Collecting gunicorn==20.0.4
remote:          Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote:        Collecting hashids==1.3.1
remote:          Downloading hashids-1.3.1-py2.py3-none-any.whl (6.6 kB)
remote:        Collecting idna==2.10
remote:          Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
remote:        Collecting itsdangerous==2.0.1
remote:          Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
remote:        Collecting Jinja2==3.0.1
remote:          Downloading Jinja2-3.0.1-py3-none-any.whl (133 kB)
remote:        Collecting MarkupSafe==2.0.1
remote:          Downloading MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
remote:        Collecting python-dateutil==2.8.1
remote:          Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
remote:        Collecting python-dotenv==0.17.1
remote:          Downloading python_dotenv-0.17.1-py2.py3-none-any.whl (18 kB)
remote:        Collecting requests==2.25.1
remote:          Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
remote:        Collecting six==1.16.0
remote:          Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
remote:        Collecting urllib3==1.26.5
remote:          Downloading urllib3-1.26.5-py2.py3-none-any.whl (138 kB)
remote:        Collecting webassets==2.0
remote:          Downloading webassets-2.0-py3-none-any.whl (142 kB)
remote:        Collecting Werkzeug==2.0.1
remote:          Downloading Werkzeug-2.0.1-py3-none-any.whl (288 kB)
remote:        Building wheels for collected packages: contentful, contentful-management
remote:          Building wheel for contentful (setup.py): started
remote:          Building wheel for contentful (setup.py): finished with status 'done'
remote:          Created wheel for contentful: filename=contentful-1.13.0-py3-none-any.whl size=23484 sha256=4e9ed2216013ef878985095ecdef4bd5b093ad3cbd269d5630a88016b7f13544
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-dvbrmrc3/wheels/65/58/bf/7fd9898c0cf50c98ce0ec77ba81cf6b06c54fc5ef13cbdf260
remote:          Building wheel for contentful-management (setup.py): started
remote:          Building wheel for contentful-management (setup.py): finished with status 'done'
remote:          Created wheel for contentful-management: filename=contentful_management-2.11.0-py3-none-any.whl size=71724 sha256=c8fa877ec3fb64a11dbbf6dbb10d015fcdc8efbb6ea1c02f1df6a717f88c5533
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-dvbrmrc3/wheels/00/cc/2b/c8d92b042eafa41d358a214cd49cb4b8ed01250b000488cb23
remote:        Successfully built contentful contentful-management
remote:        Installing collected packages: certifi, chardet, click, colorama, urllib3, idna, requests, six, python-dateutil, contentful, contentful-management, Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask, webassets, Flask-Assets, gunicorn, hashids, python-dotenv
remote:        Successfully installed Flask-2.0.1 Flask-Assets-2.0 Jinja2-3.0.1 MarkupSafe-2.0.1 Werkzeug-2.0.1 certifi-2021.5.30 chardet-4.0.0 click-8.0.1 colorama-0.4.4 contentful-1.13.0 contentful-management-2.11.0 gunicorn-20.0.4 hashids-1.3.1 idna-2.10 itsdangerous-2.0.1 python-dateutil-2.8.1 python-dotenv-0.17.1 requests-2.25.1 six-1.16.0 urllib3-1.26.5 webassets-2.
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 52.8M
remote: -----> Launching...
remote:        Released v3
remote:        https://stackcwww.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/stackcwww.git
 * [new branch]      master -> master

【讨论】:

  • 感谢您的回答!是的,当我意识到这可能是编码问题时,我已经修复了它。您的回答对未来的用户很有价值,感谢您花时间验证和解决问题:D
猜你喜欢
  • 2013-11-19
  • 2021-01-26
  • 2020-11-28
  • 2017-05-07
  • 2016-10-19
  • 2019-11-19
  • 2017-02-02
  • 2023-03-31
相关资源
最近更新 更多