heroku部署Python版本问题

新手上路,请多包涵

本人在Mac上部署网页,部署开始:

wumengtiandeMacBook-Pro:web wumengtian$ git push heroku master

但出现了问题:

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing Python-3.6.2
remote:  !     Requested runtime (Python-3.6.2) is not available for this stack (heroku-16).
remote:  !     Aborting.  More info: https://devcenter.heroku.com/articles/python-support
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !    Push rejected to safe-peak-44258.

前几天在windows系统部署都没有问题,现在出现pyhon版本不能用,于是我去看了提示的网站:https://devcenter.heroku.com/...
图片描述

没有问题啊 我用的就是Python-3.6.2啊 然后又用Mac自带的2.7.10部署 还是显示上图一样的错误:2.7.10 is not available....
问下朋友们问题真的出在版本上吗?还是其他地方出错了?谢谢各位!

阅读 7.5k
2 个回答

看了一圈帮助网站,建议使用 Python 3.5.1-3 试一试。

报错中提供的 Python Support 页面确实显示支持 Python 3.6.2,但在 Ubuntu Packages on Heroku Stacks 页面中,heroku-16 未显示支持 Python 3.6.2。如下图,中间一栏是旧版 cedar-14,右边一栏是 heroku-16。

Installed Ubuntu Packages

可以看到,heroku-16 中的 python3 命令是支持 python 3.5.1-3 的。

考虑到几天前还可以部署,可能的原因是近期 Heroku 作出了修改。注意 Python Support 页面的最近更新时间是 17 July 2017,而 Ubuntu Packages on Heroku Stacks 页面是刚刚更新的,更新时间是 23 August 2017。另外,heroku-16 介绍页面 Heroku-16 Stack 也写着支持 python 3.6,但更新时间是 6 June 2017。

所以,如果以最新的说明为准,heroku-16 目前不能部署 Python 3.6,建议在电脑上使用 virtualenv 建立虚拟 Python 环境或者暂时降级为 3.5。

新手上路,请多包涵

问题解决了,主要是runtime.txt的问题,我把它删除了重新编辑后就再没有出现上述问题,我也很纳闷为什么会这样。之前的runtime.txt都是从部署过的文件里复制粘贴过来的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题