【问题标题】:Deploying Flask app on Heroku giving build error在 Heroku 上部署 Flask 应用程序给出构建错误
【发布时间】:2018-04-15 16:25:19
【问题描述】:

我在 python 中提出了一个烧瓶应用程序,它在 localhost 服务器上运行良好。

现在在云服务 Heroku 上部署它时,构建失败并出现以下错误:

remote:          Downloading distribute-0.6.24.tar.gz (620kB)
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-install-_ofp1xky/distribute/setuptools/__init__.py", line 2, in <module>
remote:                from setuptools.extension import Extension, Library
remote:              File "/tmp/pip-install-_ofp1xky/distribute/setuptools/extension.py", line 2, in <module>
remote:                from setuptools.dist import _get_unpatched
remote:              File "/tmp/pip-install-_ofp1xky/distribute/setuptools/dist.py", line 103
remote:                except ValueError, e:
remote:                                 ^
remote:            SyntaxError: invalid syntax
remote:            
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-_ofp1xky/distribute/
remote:  !     Push rejected, failed to compile Python app.

下面是我的 requirements.txt::

docutils==0.11

MarkupSafe==0.19
Pygments==1.6
Sphinx==1.2.2

requests==1.2.0
Flask==0.10.1
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2

请帮忙!感谢 Flask 的新手。

【问题讨论】:

  • 你用的是哪个版本的python?
  • 我正在使用 python 2.7

标签: python heroku flask deployment build-error


【解决方案1】:

看来您应该将distribute 要求更新为distribute-0.7.3 的发布。还要记住,heroku 支持最新的 python,但如果你想支持https://devcenter.heroku.com/articles/python-runtimes

,你可以更改运行时

除此之外,您可以完全删除 distribute,因为它不是必需的,它只是 heroku 中的一个示例。 Flask 应用可以在没有这个的情况下运行。

最好使用 Pipfile 的推荐样式而不是要求。

如果你想查看 https://github.com/yefim/flask-heroku-sample,这是一个很好的 heroku 烧瓶示例

【讨论】:

    猜你喜欢
    • 2020-10-21
    • 1970-01-01
    • 2022-06-30
    • 1970-01-01
    • 1970-01-01
    • 2017-07-07
    • 2018-07-26
    • 1970-01-01
    相关资源
    最近更新 更多