【问题标题】:Pipfile.lock out of datePipfile.lock 已过期
【发布时间】:2018-09-02 18:28:06
【问题描述】:

我正在尝试将一个大型 django 项目部署到 heroku。我安装了 Heroku CLI,登录,创建了一个应用程序并运行:

git push heroku master

我已经设置了 Pipfile 和 requirements.txt。我添加了一个 runtime.txt 来指定我需要 python 2.7。这也在 Pipfile 中。这就是我从推送到 heroku 得到的:

$ git push heroku master
Counting objects: 12159, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4853/4853), done.
Writing objects: 100% (12159/12159), 20.94 MiB | 1.82 MiB/s, done.
Total 12159 (delta 6859), reused 12036 (delta 6751)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing python-3.6.4
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote:        Your Pipfile.lock (3b2ba9) is out of date. Expected: (83a5b4).
remote:        Aborting deploy.
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to camp-infinity.
remote: 
To https://git.heroku.com/camp-infinity.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/camp-infinity.git'

由于某种原因,它尝试安装 python 3,而且它也不喜欢我的 Pipfile.lock 文件。我尝试删除它并使用 pipenv install 再次生成它,但这并没有改变任何东西。

【问题讨论】:

  • 你本地的 Pipenv 安装也是 11.8.2 吗?
  • 本地 Pipenv 版本不同。但是“11.8.2”是硬编码在github.com/heroku/heroku-buildpack-python/blob/master/bin/steps/…
  • 我遇到了同样的问题,唯一的解决方案是删除 Pipfile.lock 文件并提交
  • 这个问题也可能是pipenv install -e .引起的。如果您需要在 travis 上运行测试,请尝试将 pipenv install -e . 添加到您的 .travis.yaml 中的 install 条目。

标签: python django heroku


【解决方案1】:

在做一个项目时遇到同样的问题,在你推送到 Heroku 的分支中,运行

pipenv lock

它会更新 Pipfile.lock 文件。 :)

【讨论】:

    【解决方案2】:

    我删除了Pipfile.lock 并提交了删除。 Heroku 的构建过程抱怨它不存在,但它确实部署成功...

    -----> Python app detected
     !     No 'Pipfile.lock' found! We recommend you commit this into your repository.
    -----> Installing pip
    -----> Installing dependencies with Pipenv 11.8.2…
           Installing dependencies from Pipfile…
    -----> Discovering process types
           Procfile declares types -> worker
    -----> Compressing...
           Done: 189.9M
    -----> Launching...
           Released v5
    

    【讨论】:

    • 这有点违背了拥有锁文件的目的,即确保开发和生产同步。
    【解决方案3】:

    如果已经创建了 Pipfile,请将其删除并再次推送部署。它应该重新安装您的依赖项。这对我有用。

    【讨论】:

      【解决方案4】:

      更新我的 pipenv:pip install pipenv --upgrade 然后做:pipenv lock 然后做一个提交

      帮我解决了这个问题

      【讨论】:

        【解决方案5】:

        处理这个最简单的方法是运行: pipenv lock 然后git commit -am "updated pipfile", git push && git push heroku master

        这些命令与其他问题中列出的一些其他命令执行完全相同的操作,但是这些命令可能会更快一些。

        【讨论】:

          【解决方案6】:

          您应该提供:

          1. Pipfile 和对应的Pipfile.lock

          或

          1. requirements.txt(以及可选的runtime.txt)

          如果您使用的是Pipfile,那么git rm requirements.txt runtime.txt 并确保使用git add Pipfile Pipfile.lock。 git commit 然后尝试你的 git push 到 heroku。

          https://devcenter.heroku.com/articles/python-runtimes

          【讨论】:

          • 我删除了 requirements.txt 和 runtime.txt 并再次尝试。没啥事儿。我确保在 Pipfile 中指定了正确的 python 版本,然后运行 ​​pipnv lock 并再次尝试。没啥事儿。它仍然尝试安装 python 3 并失败并显示相同的消息。
          • 在推送到 heroku 之前,正确的 Pipfile 和 Pipfile.lock 是否已提交给 git?
          • 是的,他们已经提交了
          • 你能发布你的Pipfile和Pipfile.lock吗?
          【解决方案7】:

          我遇到了同样的问题,这是由于指向 Pipfile.lock 的符号链接造成的。

          在我的本地 mac OS 环境中克隆 repo 后,由于某些原因,原始链接有点损坏,这导致在推送到 Heroku 时出现Your Pipfile.lock (3b2ba9) is out of date. Expected: (83a5b4)。

          只需删除“旧”符号链接并从我的本地环境重新创建它即可解决问题。

          【讨论】:

            【解决方案8】:

            使用 Heroku CLI,我正在从不是 master 的本地分支运行 git push heroku master,这时出现了这个确切的错误:

            remote: -----> Python app detected
            remote: -----> Installing pip
            remote: -----> Installing dependencies with Pipenv 2018.5.18…
            remote:        Your Pipfile.lock (38bf21) is out of date. Expected: (e4987e).
            remote:        Aborting deploy.
            remote:  !     Push rejected, failed to compile Python app.
            remote:
            remote:  !     Push failed
            remote: Verifying deploy...
            

            从master 分支部署修复了它。

            如果您想将本地分支推送到不是 master 的 Heroku 主服务器,请运行 git push heroku branchname:master。

            【讨论】:

              【解决方案9】:

              我今天遇到了同样的问题,所以我通过更新我的 pipenv - pip install pipenv --upgrade 然后点击 pipenv lock 解决了下面提到的问题。这是要走的路,并且解决了大多数情况。另外,在那之后不要忘记 git add、commit 和 push to heroku!希望对您有所帮助!

              【讨论】:

                【解决方案10】:

                还有一个提示:如果您对Pipfile.lock 进行了更新并且没有看到任何更改,请确保执行git add . 和git commit -m "whatever"。 :)

                【讨论】:

                  猜你喜欢
                  • 2018-11-24
                  • 2018-09-03
                  • 1970-01-01
                  • 2013-01-23
                  • 2018-12-01
                  • 1970-01-01
                  • 2012-03-12
                  • 2019-10-21
                  • 2018-02-21
                  相关资源
                  最近更新 更多