【问题标题】:Heroku not install anything listed in requirements.txtHeroku 不安装 requirements.txt 中列出的任何内容
【发布时间】:2017-12-06 00:37:00
【问题描述】:

我不是以英语为母语的用户,我是 Python 初学者。请原谅任何语法错误。

我无法将一个简单的烧瓶项目推送到 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 中可以正常工作。

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

谢谢。

【问题讨论】:

    标签: python heroku flask


    【解决方案1】:

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

    pipenv install -r requirements.txt

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

    【讨论】:

    • OP 使用的是pip,而不是 Pipenv:“使用 pip 安装需求”。没关系。
    猜你喜欢
    • 2020-09-05
    • 1970-01-01
    • 2020-11-26
    • 2017-02-11
    • 2017-05-03
    • 2021-06-28
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多