【问题标题】:Push rejected, failed to compile Python app in heroku (Python Crash Course)Push 被拒绝,无法在 heroku 中编译 Python 应用程序(Python Crash Course)
【发布时间】:2019-12-24 21:13:29
【问题描述】:

我正在研究 Eric Matthes 在 Python Crash Course 中的学习日志项目,特别是在学习日志应用程序上工作。我正在尝试部署到 heroku 但收到此错误:

(ll_env) C:\Users\benpg\Documents\Coding\Python\learning_log>git push heroku master
Enumerating objects: 54, done.
Counting objects: 100% (54/54), done.
Delta compression using up to 4 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (54/54), 16.54 KiB | 940.00 KiB/s, done.
Total 54 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.7.3
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to pacific-refuge-12657.
remote:
To https://git.heroku.com/pacific-refuge-12657.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pacific-refuge-12657.git'

尝试了所有here,包括一开始链接的另外两个问题,没有运气。

这是我的 requirements.txt:

Django==1.8.4
dj-database-url==0.3.0
dj-static==0.0.6
django-bootstrap3==6.2.2
gunicorn==19.3.0
static3==0.6.1
psycopg2>=2.6.1

编辑: 我正在使用 django 2.2.4。我的 requirements.txt 就是这样,因为书中有一条注释说“如果您使用的是 Windows,请确保您的 requirements.txt 版本与此处显示的列表匹配,无论您能够安装哪些软件包”。这是为什么呢?

这是我拥有的第一个 requirements.txt,除了最后一行之外是自动生成的。这个也不起作用,同样的错误信息:

dj-database-url==0.5.0
dj-static==0.0.6
Django==2.2.4
django-bootstrap3==11.1.0
gunicorn==19.9.0
pytz==2019.2
sqlparse==0.3.0
static3==0.7.0
psycopg2>=2.6.1

【问题讨论】:

  • 您的requirements.txt 是否与manage.py 处于同一级别?还要检查拼写。
  • Django 1.8.4 已经过时多年,没有收到安全更新。支持 Python 3.5 的 Django 1.8 与 Heroku which supports Python 3.6 和 3.7 之间存在不匹配(两者都支持 Python 2,但对于新项目您应该避免使用 Python 2。
  • 同时更新 Django 最新版本。或者至少1.11.x
  • 我会避免遵循为 Django 1.8 编写的教程。从那以后发生了很多变化,所以你会遇到这样的问题。我对python-crash-course这本书不熟悉,所以我不知道是否有使用更新版本的Django的更新版本。 pcc repo 似乎有一个为 Django 2.0 更新的项目副本,这可能会对您有所帮助。
  • @MD。 Khairul Basar 要求在正确的目录中,已检查拼写

标签: python django python-3.x heroku


【解决方案1】:

刚刚遇到同样的问题,将 Python 版本改回 3.7.3 修复了它。能够构建python并执行。

【讨论】:

    猜你喜欢
    • 2014-06-07
    • 2019-10-25
    • 2013-05-01
    • 1970-01-01
    • 2013-03-22
    • 2014-04-14
    • 2017-04-27
    • 2017-01-17
    • 1970-01-01
    相关资源
    最近更新 更多