Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Heroku/python未能检测到集合构建包_Python_Django_Git_Heroku_Deployment - Fatal编程技术网

Heroku/python未能检测到集合构建包

Heroku/python未能检测到集合构建包,python,django,git,heroku,deployment,Python,Django,Git,Heroku,Deployment,我是Django新手,我创建了一个应用程序,并希望使用Heroku进行部署。然而,当我推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

我是Django新手,我创建了一个应用程序,并希望使用Heroku进行部署。然而,当我推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
将所有模块冻结到一个文件中。我只建议您在使用virtualenv时这样做,否则它会添加所有模块

总之,只需准确地确定应用程序需要哪些模块,并创建一个名为
requirements.txt
的文件,然后将其放入应用程序目录中

需求文件的语法如下所示:

package name == version #
package name == version #
package name == version #
注意:指定特定版本号是可选的

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


别忘了提交requirements.txt

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

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

  • 在应用程序文件夹中创建requirements.txt文件

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

  • 现在提交您的更改

    git添加

    git提交-m“添加了需求”

    git推送heroku主机

  • 在我的例子中,这里有一个陷阱:我没有添加任何模块,因为pip也可以自动从本地代码库安装依赖项。运行命令后,当我检查requirement.txt文件时,已经自动添加了模块

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

  • 这一步只有当你得到一个类似于我的例子的错误,我得到了一个关于conda==版本找不到的错误。由于模块是根据我的本地代码库自动添加的,所以Conda版本安装在我的本地机器上,这就是为什么它会自动添加到我的requirement.txt文件中。您所要做的就是将其从requirements.txt文件中删除

  • 再次提交更改


  • 我想这可能会帮助一些遇到类似错误的人。

    我得到了完全相同的错误,但也按照你的建议做了。执行“git add.”并将更改提交到git!
    Flask==0.11
    Jinja2==2.8
    gunicorn==19.6.0