我希望你能帮助我,我开发了一个 Flask 应用程序,我正在尝试部署到 heroku。
我研究并遵循了我在 YouTube 视频等中遇到的步骤
我的 git 树很干净,我有一个包含所有依赖项的requirements.txt 文件,我的根文件夹中有一个 Procfile(没有扩展名),但在尝试运行时我不断收到此错误消息
git Push heroku main
-----> Building on the Heroku-22 stack -----> Using buildpack: https://github.com/heroku/heroku-buildpack-python.git -----> App not compatible with buildpack: https://github.com/heroku/heroku-buildpack-python.git More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure ! Push failed
我尝试删除该应用程序并重新开始,但没有运气,我已阅读所有类似的问题,但没有发现任何问题是导致此问题的原因。
我还尝试将heroku堆栈设置为20,然后在不起作用时恢复到22。
非常令人沮丧,heroku 支持尚未回复我的请求。有人可以帮忙吗?
这是我的要求.txt
alembic==1.13.1
amqp==5.2.0
aniso8601==9.0.1
annotated-types==0.6.0
anyio==4.2.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
async-lru==2.0.4
attrs==23.2.0
Babel==2.14.0
bcrypt==4.1.2
beautifulsoup4==4.12.2
billiard==4.2.0
bleach==6.1.0
blinker==1.7.0
bs4==0.0.1
celery==5.3.6
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
colorama==0.4.6
comm==0.2.1
cx_Oracle==8.3.0
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
dnspython==2.4.2
email-validator==2.1.0.post1
et-xmlfile==1.1.0
executing==2.0.1
fastapi==0.108.0
fastjsonschema==2.19.1
Flask==3.0.0
Flask-Admin==1.6.1
Flask-Bcrypt==1.0.1
Flask-Cors==4.0.0
Flask-DebugToolbar==0.14.1
Flask-Login==0.6.3
Flask-Mail==0.9.1
Flask-Migrate==4.0.5
Flask-RESTful==0.3.10
Flask-SQLAlchemy==3.1.1
Flask-Uploads==0.2.1
Flask-WTF==1.2.1
fqdn==1.5.1
gitdb==4.0.11
GitPython==3.1.41
greenlet==3.0.3
gunicorn==21.2.0
html5lib==1.1
idna==3.6
iniconfig==2.0.0
ipykernel==6.28.0
ipython==8.20.0
isoduration==20.11.0
itsdangerous==2.1.2
jedi==0.19.1
Jinja2==3.1.2
json5==0.9.14
jsonpointer==2.4
jsonschema==4.20.0
jsonschema-specifications==2023.12.1
jupyter-events==0.9.0
jupyter-lsp==2.2.1
jupyter-server-mathjax==0.2.6
jupyter_client==8.6.0
jupyter_core==5.7.1
jupyter_server==2.12.4
jupyter_server_terminals==0.5.1
jupyterlab==4.0.10
jupyterlab_git==0.50.0
jupyterlab_pygments==0.3.0
jupyterlab_server==2.25.2
jupytext==1.16.1
kombu==5.3.4
lckr_jupyterlab_variableinspector==3.1.0
lxml==5.1.0
Mako==1.3.0
markdown-it-py==3.0.0
MarkupSafe==2.1.3
matplotlib-inline==0.1.6
mdit-py-plugins==0.4.0
mdurl==0.1.2
mistune==3.0.2
multimethod==1.10
mypy-extensions==1.0.0
mysql-connector-python==8.3.0
nbclient==0.9.0
nbconvert==7.14.1
nbdime==4.0.1
nbformat==5.9.2
nest-asyncio==1.5.8
notebook==7.0.6
notebook_shim==0.2.3
numpy==1.26.3
openpyxl==3.1.2
overrides==7.4.0
packaging==23.2
pandas==2.1.4
pandera==0.18.0
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.9.0
platformdirs==4.1.0
plotly==5.18.0
pluggy==1.3.0
prometheus-client==0.19.0
prompt-toolkit==3.0.43
psutil==5.9.7
psycopg2==2.9.9
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
pydantic==2.5.3
pydantic_core==2.14.6
Pygments==2.17.2
pyodbc==5.0.1
pytest==7.4.4
python-dateutil==2.8.2
python-json-logger==2.0.7
pytz==2023.3.post1
pywin32==306
pywinpty==2.0.12
PyYAML==6.0.1
pyzmq==25.1.2
referencing==0.32.1
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.17.1
Send2Trash==1.8.2
six==1.16.0
smmap==5.0.1
sniffio==1.3.0
soupsieve==2.5
SQLAlchemy==2.0.25
stack-data==0.6.3
starlette==0.32.0.post1
tenacity==8.2.3
terminado==0.18.0
tinycss2==1.2.1
toml==0.10.2
tornado==6.4
traitlets==5.14.1
typeguard==4.1.5
types-python-dateutil==2.8.19.20240106
typing-inspect==0.9.0
typing_extensions==4.9.0
tzdata==2023.4
uri-template==1.3.0
urllib3==2.1.0
vine==5.1.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
Werkzeug==3.0.1
wrapt==1.16.0
WTForms==3.1.2
xeus-python==0.15.12
xeus-python-shell==0.5.0
xlwings==0.30.13
我使用的是python 3.12.1
所以我终于弄清楚问题是什么了。我希望这对其他人有帮助。
首先确保您的 Flask 文件夹结构与部署在 Heroku 上的结构相同,因此,例如,如果您正在主存储库中工作,并且您的 Flask 应用程序位于存储库深处的几个级别,那么在部署到 Heroku 时,这将导致出现问题。您只需要部署包含 Flask 应用程序的文件夹,因为根文件夹级别(requirements.txt、Profile)需要大量依赖项,如果不存在,这些依赖项将阻止成功部署。
其次,如果有已升级的软件包,它们可能不再与heroku上运行的python版本兼容,您可能需要枯萎降级或完全从部署中排除。
最后,如果您使用 postgres 数据库,则需要将数据库 url 的第一部分从 postgres 修改为 postgresql,不是在 heroku 中修改,因为这是不可能的,而是在配置文件中使用替换字符串方法。
希望这对某人有帮助。