【问题标题】:Heroku is using the wrong requirements.txt when I try to git push my app当我尝试 git push 我的应用程序时,Heroku 使用了错误的 requirements.txt
【发布时间】:2019-02-08 22:38:51
【问题描述】:

我第一次尝试将 django 应用程序安装到 Heroku。我一直在关注教程,在git push heroku master 之前一切都很顺利。我收到 postgrequl/psycopg2 错误:

Collecting psycopg2==2.6.2 (from -r /tmp/build_9a1b9401a05f6186e32ef1f993bdd183/requirements.txt (line 10))
remote:          Downloading blah...blah../bc/psycopg2-2.6.2.tar.gz (376kB)
remote:            Complete output from command python setup.py egg_info:
remote:            running egg_info
remote:            creating pip-egg-info/psycopg2.egg-info
remote:            writing pip-egg-info/psycopg2.egg-info/PKG-INFO
remote:            writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
remote:            writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
remote:            writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
remote:            Error: could not determine PostgreSQL version from '10.5'
remote:
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mu5yzi1s/psycopg2/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to django-randomizer.

我进行了一些搜索,并阅读了其他人遇到问题的地方,因为他们使用的是旧版本的 psycopg2。所以我编辑了我的 requirements.txt 文件以包含psycopg2-2.7.5,这是最新的。我想再次尝试“git push heroku master”,我得到了同样的错误。错误引用 psycopg2-2.6.2。

我什至删除了我的应用程序并重新启动,但是当涉及到 git push 时,我得到了同样的错误。目前我认为 git 处于某种状态,它一直在尝试进行已经失败的推送。不过我不确定。有什么想法吗?

git reflog:
5fd142e (HEAD -> deployheroku, origin/deployheroku) HEAD@{0}: pull origin deployheroku: Fast-forward
df048a9 (origin/master, origin/HEAD, master) HEAD@{1}: reset: moving to HEAD^
5fd142e (HEAD -> deployheroku, origin/deployheroku) HEAD@{2}: commit: change settings and wsgi for heroku
df048a9 (origin/master, origin/HEAD, master) HEAD@{3}: checkout: moving from master to deployheroku
df048a9 (origin/master, origin/HEAD, master) HEAD@{4}: commit: restore local version
873d636 HEAD@{5}: commit: updated psycopg2 in requirements.txt
aebfe43 HEAD@{6}: commit: get files ready for heroku
6273553 HEAD@{7}: commit: removed old files
9b2c347 HEAD@{8}: commit: update with new app name
6b4103d HEAD@{9}: clone: from https://github.com/shmish/django-randomizer.git

我的 requirements.txt 是:

certifi==2018.8.13
chardet==3.0.4
defusedxml==0.5.0
Django==2.0.8
django-allauth==0.36.0
django-filter==2.0.0
docopt==0.6.2
idna==2.7
oauthlib==2.1.0
psycopg2==2.7.5
python-decouple==3.1
python3-openid==3.1.0
pytz==2018.5
requests==2.19.1
requests-oauthlib==1.0.0
urllib3==1.23
whitenoise==4.0
yarg==0.1.9

【问题讨论】:

  • 我编辑了问题并包含了 requirements.txt
  • psycopg2==2.7.5masterdeployheroku 中吗?我清楚地看到psycopg2==2.6.2。你能告诉我们git show master:requirements.txt | grep psycopg2git show deployheroku:requirements.txt | grep psycopg2的结果吗?
  • $ git show deployheroku:requirements.txt | grep psycopg2 psycopg2==2.7.5
  • $ git show master:requirements.txt | grep psycopg2 psycopg2==2.6.2
  • 你没有在部署中使用 dj-database-url 吗?我也会使用 psycopg2==2.7.1 并且不在 Heroku 上运行最新版本。为确保您的 requirements.txt 文件用于最近的部署尝试,请输入您对文件的更改,即 git add 。 git commit -m 'changes to requirements.txt' 最后是 git push heroku master。

标签: django git heroku


【解决方案1】:
$ git show master:requirements.txt | grep psycopg2
psycopg2==2.6.2

所以你部署了一个错误的分支。在master 中部署deployheroku 或更新requirements.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 2015-03-27
    • 2020-09-25
    • 2013-02-28
    相关资源
    最近更新 更多