第一次使用Heroku。试图推动。我已运行命令:
heroku create --buildpack heroku/python
它显示了
$ heroku create --buildpack heroku/python
Creating app... done, glacial-reef-7599
Setting buildpack to heroku/python... done
https://glacial-reef-7599.herokuapp.com/ | https://git.heroku.com/glacial-reef-7599.git
堆栈跟踪:
$ git push heroku master
Counting objects: 129, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (124/124), done.
Writing objects: 100% (129/129), 69.06 KiB | 0 bytes/s, done.
Total 129 (delta 22), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to pure-badlands-9125.
remote:
To https://git.heroku.com/pure-badlands-9125.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-badlands-9125.git'
我肯定错过了什么
我已将requirements.txt
添加到我的根目录中。看起来是这样的:
.git
.idea
projectapp
projectname
rango
db.sqlite3
manage.py
populate_rango.py
requirements.txt
对于将来的引用,必须确保使用代码将分支推送到
heroku master
如果您从
master
分支进行分支,并且所有代码都在一个develop
上,那么将其推送到heroku主机因此,不是:
您可以执行以下操作:
这个问题有关于这个问题的重要细节
您需要创建一个runtime.txt文件。在命令行上,在requirements.txt文件所在的文件夹中,输入
echo "python-3.5.1" > runtime.txt
。当然,请确保将3.5.1与您正在使用的Python版本切换快速解决方案
TLDR
实际上,heroku所做的是,它试图通过查看项目中的文件来确定您正在部署的项目,例如,如果您的项目有
package.json
文件,它就会理解它是一个nodejs项目,如果您的项目有requirements.txt
文件,它就会理解它是一个python项目,等等,请参见this document了解您可以在heroku服务器上运行的语言正如您所知,要在计算机中运行特定项目(如nodejs项目),必须在该计算机中安装节点运行时,否则无法在计算机中运行nodejs应用程序,heroku会做什么?它在不同的容器中运行您的每个应用程序,这意味着在一个容器中,只有一个应用程序正在运行,当然,容器已经安装了nodejs,因此,如果一个容器只运行一个应用程序,那么在容器中安装所有其他运行时是没有意义的,所以在我的情况下,容器只有一个运行时,它就是nodejs。当然,他们还有其他类型的容器,比如python的一种类型,并且该容器已经安装了python运行时(特定版本),所以如果我的应用程序安装在python容器中,它将无法工作,因为我的应用程序在nodejs中。出于这个原因,我们需要在开始时确定应用程序的类型,以选择正确的容器类型,主要是heroku自动检测到它,但如果它无法检测到,则必须通过转到其仪表板设置或通过项目中的运行时文件显式地进行判断,你可能已经注意到,你只做过一次
相关问题 更多 >
编程相关推荐