gpt4 book ai didi

python - Heroku 不安装 requirements.txt 中列出的任何内容

转载 作者:太空宇宙 更新时间:2023-11-03 11:20:02 25 4
gpt4 key购买 nike

I'm not a native English user and I'm a Python beginner. Please excuse any grammar error.

我在将一个简单的 flask 项目推送到 Heroku 时遇到问题。

The project is on Github

首先,我的 requirements.txt 如下所示:

click==6.7
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
Werkzeug==0.12.2

但是,Heroku 返回错误码

remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.1
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote: Failed to import the site module
remote: Traceback (most recent call last):
remote: File "/tmp/build_b20ee4f76cefa5dfa20998cf2e3692c7/site.py", line 1, in <module>
remote: from flask import Flask, render_template
remote: ModuleNotFoundError: No module named 'flask'
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed

我已经在 venv 和全局环境中成功运行该项目,并在 venv 激活和停用模式下多次运行 ./venv/bin/pip freeze 命令。 ./venv/bin/pip -r install requirements.txt 在新的 venv 中可以正常工作。

我不确定我做错了哪一步。任何建议都会有所帮助。

谢谢。

最佳答案

requirements.txt信息需要包含在Pipfile中。在本地 pipenv 上,我使用了:

pipenv install -r requirements.txt

这也更新了 Pipfile。然后提交并推送到 heroku。希望这会有所帮助。

关于python - Heroku 不安装 requirements.txt 中列出的任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44873767/

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