Python 为了将其推送到Heroku,我应该向Django目录中的requirements.txt添加什么?

Python 为了将其推送到Heroku,我应该向Django目录中的requirements.txt添加什么?,python,django,git,heroku,Python,Django,Git,Heroku,我是编程/web开发新手,我想将Django目录推送到heroku。但每次我在命令行中输入“git push heroku master”时,都会出现相同的错误: "Could not find a version that satisfies the requirement bonjour-py==0.3 (from -r /tmp/build_602f#############86ff270e/requirements.txt (line 3)) (from versions: )" 我激

我是编程/web开发新手,我想将Django目录推送到heroku。但每次我在命令行中输入“git push heroku master”时,都会出现相同的错误:

"Could not find a version that satisfies the requirement bonjour-py==0.3 (from -r /tmp/build_602f#############86ff270e/requirements.txt (line 3)) (from versions: )"

我激活了虚拟环境,但没有用。现在我假设问题可能是我的requirements.txt文件不包含任何内容(因为我认为无论如何都没有理由这样做)。不过,我想知道什么是“你好,py==0.3”,以及如何解决这个问题。非常感谢你的帮助

在Python虚拟环境和项目路径中,只需键入:

pip freeze>requirements.txt


这将在
requirements.txt
文件中列出您使用的每个python包的确切版本。这就是Heroku知道运行Django应用程序需要安装哪些软件包的方式。

问题是,python2.7和python3.x是不同的版本。您需要相同版本的python-server和local

待办事项:

  • 使用终端并转到项目目录

    cd/your/path/to/project/

  • 激活你的虚拟电视

    源环境/箱/激活

  • 使用pip生成requirements.txt

    pip freeze>requirements.txt

  • 转到服务器并使用相同的python版本创建新的virtualenv()

    virtualenv--python=python2.7env

  • 在服务器上激活virtualenv

    源环境/箱/激活

  • 使用pip安装requirements.txt

    pip安装-r requirements.txt

  • Django迁移

    python manage.py迁移

  • 使用runserver启动django(测试)或连接Web服务器(nginx、uwsgi、gunicorn等)

    python manage.py运行服务器


  • 还要确保使用与heroku相同的Python版本。至少不要混合使用Python 2和Python 3。很多lib对于某些Python版本是不可用的。我相信我现在使用的Python版本是错误的。我使用的是python-2.7.10,我想这会导致冲突。我将python更新为python-3.6.2,但我的终端仍然告诉我我使用python-2.7.10。创建别名也不起作用。有什么办法解决这个问题吗?你可以按照Kostas的答案来做,或者,如果真的只缺少了
    bonjour py
    ,用
    pip install bonjour py
    在heroku上安装它。