【问题标题】:I cant deploy my flask app on heroku我无法在 heroku 上部署我的烧瓶应用程序
【发布时间】:2014-11-26 12:57:52
【问题描述】:

我是 heroku 的新手,我正在尝试在那里部署我的应用程序。但它失败了,我收到以下消息:

   Command /app/.heroku/python/bin/python -c "import setuptools, tokenize;__
   file__='/tmp/pip_build_u21590/matplotlib/setup.py';exec(compile(getattr(tokenize
, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record /tmp/pip-4IJQX6-record/install-record.txt --single-version-external
ly-managed --compile failed with error code 1 in /tmp/pip_build_u21590/matplotli
b
Traceback (most recent call last):
File "/app/.heroku/python/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/
__init__.py", line 185, in main
return command.main(cmd_args)
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/
basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 70: ordinal
not in range(128)

!     Push rejected, failed to compile Python app

To git@heroku.com:salty-oasis-2440.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:salty-oasis-2440.git'

以上是我的要求清单:

  • 烧瓶==0.10.1
  • configobj==5.0.0
  • gunicorn==19.1.1
  • 其危险==0.24
  • jinja2==2.7.2
  • matplotlib==1.3.1
  • networkx==1.8.1
  • numpy==1.8.1
  • pyparsing==1.5.7
  • python-dateutil==2.2
  • werkzeug==0.9.4

我做错了什么?

提前致谢!!!

【问题讨论】:

  • complete_log 可能有一个 unicode 字符。最后尝试 .encode() 方法检查它是否有效。
  • 试试看(文件)requirements.txt的编码

标签: python heroku deployment flask


【解决方案1】:

在项目的工作 virtualenv 中输入以下命令:

pip freeze > requirements.txt

注意:如果您的项目没有 virtualenv,请考虑为您的项目创建一个 virtualenv,然后在其中安装所有要求并再次运行上述命令。

然后将新的requirements.txt 添加到您的项目存储库并将其推送到heroku:

git commit requrements.txt -m "new one from pip"
git push heroku

【讨论】:

  • 这很好地描述了如何为 Heroku 应用程序生成需求,但不是问题的答案。实际问题出在pip(见我的回答)。
  • 看来你是对的。我以为 OP 已经手动编辑了需求文件。
【解决方案2】:

这不是 Heroku 的问题。这是一个 known issue with pip 未发布(截至 2014 年 11 月 26 日)修复。由于您使用的是 Python 2.7,因此您现在可以manually patch pip

【讨论】:

    猜你喜欢
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    相关资源
    最近更新 更多