我是一个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'
我的根目录:
├── assignment
├── household_management (django app)
├── templates
|
├── db.sqlite3
|
├── manage.py
如果你们能帮忙,我将不胜感激。我现在真的很沮丧。。。
以下是逐步解决上述问题的方法:
在应用程序文件夹中创建requirements.txt文件。
从同一文件夹运行命令pip freeze>;requirements.txt。
现在提交您的更改。
git添加。
git commit-m“添加了需求”
git推送heroku主机
这里有一个问题,在我的例子中:我没有添加任何模块,因为pip还可以从本地代码库自动安装依赖项。在我检查requirement.txt文件时运行命令之后,已经自动添加了模块。
注意:如果你没有遇到这种情况,你可以像哈里森在回答中所说的那样手动操作。
这一步只有当你得到一个错误类似于我的情况我得到一个关于conda==版本找不到错误。由于模块是基于本地代码库自动添加的,所以Conda版本安装在本地计算机上,这就是为什么它会自动添加到requirement.txt文件中。您只需将其从requirements.txt文件中删除。
再次提交更改。
我想这可能会帮助你们中的一些人面对类似的错误。
您只需将requirements.txt添加到您的主应用程序文件夹中,它包含我们正在处理的包,如django、flask。
您需要添加一个
requirements.txt
文件,该文件包含运行应用程序所需的所有模块。您可以通过
pip freeze > requirements.txt
将所有模块冻结到一个文件中。如果您使用的是virtualenv,我只建议您这样做,否则它将添加您的所有模块。无论如何,只需确定应用程序需要什么模块,然后创建一个名为
requirements.txt
的文件,并将其放在应用程序目录中。需求文件的语法如下:
注意:指定某个版本号是可选的。
下面是一个示例需求文件(取自this教程):
别忘了提交你的需求.txt
相关问题 更多 >
编程相关推荐