git Heroku/python 未能检测到 set buildpack

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39282911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:14:14  来源:igfitidea点击:

Heroku/python failed to detect set buildpack

pythondjangogitherokudeployment

提问by Harrison

I'm a Django newbie, I created an app and want to deploy it using Heroku. However, when I do git push heroku master(I follow Heroku's getting started), this is what I got:

我是 Django 新手,我创建了一个应用程序并想使用 Heroku 部署它。但是,当我这样做时git push heroku master(我遵循 Heroku 的入门),这就是我得到的:

Counting objects: 36, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (33/33), done.
Writing objects: 100% (36/36), 19.22 KiB | 0 bytes/s, done.
Total 36 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to dry-waters-63931.
remote: 
To https://git.heroku.com/dry-waters-63931.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dry-waters-63931.git'

My root directory:

我的根目录:

├── assignment
├── household_management (django app)
├── templates
| 
├── db.sqlite3
|
├── manage.py

I will be very appreciated if you guys can help. I'm really depressed right now...

如果你们能提供帮助,我将不胜感激。我现在真的很郁闷...

回答by Harrison

You need to add a requirements.txtfile which contains all of the modules required to run your application.

您需要添加一个requirements.txt文件,其中包含运行应用程序所需的所有模块。

You can do pip freeze > requirements.txtto freeze all of your modules into a file. I would only recommend doing this if you're using a virtualenv because otherwise it will add ALL of your modules.

您可以pip freeze > requirements.txt将所有模块冻结到一个文件中。如果您使用的是 virtualenv,我只会建议您这样做,否则它会添加您的所有模块。

Anyways, just determine exactly what modules your application requires and create a file called requirements.txtand put it in your application directory.

无论如何,只需确定您的应用程序需要哪些模块并创建一个名为的文件requirements.txt并将其放入您的应用程序目录中。

The syntax for a requirements file is as follows:

需求文件的语法如下:

package name == version #
package name == version #
package name == version #

Note: It is optional to specify a certain version number.

注意:指定某个版本号是可选的。

Here is an example requirements file (taken from thistutorial):

这是一个示例需求文件(取自教程):

Flask==0.11
Jinja2==2.8
gunicorn==19.6.0

Don't forget to commit your requirements.txt

不要忘记提交您的requirements.txt

回答by shubham kapoor

You just have to add requirements.txtto your main application folder.It contain the package that we work on like django ,flask.

您只需将requirements.txt添加到您的主应用程序文件夹中。它包含我们正在处理的包,如django、flask。

回答by Appy Sharma

Here are steps by steps you can solve the above problem:

以下是您可以解决上述问题的步骤:

  1. Create a requirements.txt file in your app folder.

  2. Run command pip freeze > requirements.txt from the same folder.

  3. Now commit your changes.

    git add .

    git commit -m "requirements added"

    git push heroku master

  1. 在您的应用程序文件夹中创建一个 requirements.txt 文件。

  2. 从同一文件夹运行命令 pip freeze > requirements.txt。

  3. 现在提交您的更改。

    git 添加。

    git commit -m "要求添加"

    git push heroku master

Here's the catch, In my case: I did it without adding any modules because pip can also install a dependency from your local codebase automatically. After running the command when i checked my requirement.txt file there were already modules added automatically.

这是问题所在,就我而言:我没有添加任何模块就完成了,因为 pip 还可以自动从本地代码库安装依赖项。当我检查我的requirement.txt文件时运行命令后,已经自动添加了模块。

NOTE: If this didn't happens to you, you can do it manually like Harrison said in his answer.

注意:如果这没有发生在你身上,你可以像哈里森在他的回答中所说的那样手动完成。

  1. This step is only if you get an error similar to my case i got an error about conda== version cant be found. As the modules have been added automatically based on my local codebase, Conda version is installed in my local machine thats why it was automatically added in my requirement.txt file. All you have to do is to remove it from the requirements.txt file.

  2. Commit your changes again.

  1. 此步骤仅当您收到与我的情况类似的错误时,我才会收到有关无法找到 conda== 版本的错误。由于模块是根据我的本地代码库自动添加的,Conda 版本安装在我的本地机器上,这就是为什么它会自动添加到我的 requirements.txt 文件中。您所要做的就是将其从 requirements.txt 文件中删除。

  2. 再次提交您的更改。

Thought it might help some of you who faced similar errors.

认为它可能会帮助你们中的一些面临类似错误的人。