【问题标题】:Cannot deploy django api with heroku无法使用 heroku 部署 django api
【发布时间】:2018-11-08 20:52:32
【问题描述】:

当我尝试使用 Heroku 部署我的 Django REST API 时,我得到了这个:

-----> Python app detected
       Using supported version of Python 3.6 (python-3.6.6)
-----> Installing python-3.6.6
-----> Installing pip
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting Python==3.5.1 (from -r /tmp/build_eff222df1413c9c747fe9d073117baf7/requirements.txt (line 1))
         Could not find a version that satisfies the requirement Python==3.5.1 (from -r /tmp/build_eff222df1413c9c747fe9d073117baf7/requirements.txt (line 1)) (from versions: )
       No matching distribution found for Python==3.5.1 (from -r /tmp/build_eff222df1413c9c747fe9d073117baf7/requirements.txt (line 1))
 !     Push rejected, failed to compile Python app.
 !     Push failed

如何设置我的 requirements.txt 以使其正常工作?我使用了一个虚拟环境,我在其中安装了这个:

django, 
djangorestframework, 
django-rest-auth, 
django-filter, 
django-cors-headers, 

我正在使用 python 3.5 和 django 2.0.1

【问题讨论】:

    标签: django heroku


    【解决方案1】:

    部署 Python 应用程序的常见做法是将 Python 版本放入 runtime.txt 文件,而不是 requirements.txt

    如果您从 requirements.txt 中删除行 python==3.5.0 并创建一个包含 python-3.5.0 内容的文件 runtime.txt,您的应用程序是否正确暂存?

    【讨论】:

    • 你是对的,我只是没有正确推送更改
    【解决方案2】:

    看起来您已将 Python 放入您的 requirements.txt 文件中。不要那样做。

    如果您确实需要将 Python 版本从 3.6 更改为 3.5,则需要将其放入 runtime.txt,而不是 requirements.txt。但实际上根本不应该有任何理由这样做。坚持使用默认版本。

    【讨论】:

    • 这是东西,我从requirements.txt中删除了python,但错误还是一样,看来heroku没有更新更改,
    猜你喜欢
    • 1970-01-01
    • 2020-07-11
    • 2013-07-16
    • 2021-09-07
    • 2017-12-09
    • 2020-09-05
    • 2013-08-22
    • 2021-07-15
    • 2020-06-14
    相关资源
    最近更新 更多