Search code examples
djangoherokupython-venvpipenv

Django Heroku pipfile lock out of date


So I recently moved from pipenv to venv, now that I try to push my changes to Heroku, I'm getting:

-----> Installing pip 23.3.1, setuptools 68.0.0 and wheel 0.41.3
-----> Installing dependencies with Pipenv 2023.7.23
       Your Pipfile.lock (old_hash[-6:]) is out of date. Expected: ({new_hash[-6:]}).
       Usage: pipenv install [OPTIONS] [PACKAGES]...

How can I migrate to venv and not use pipenv anymore in Heroku? should I delete my pipfilelock? or should I go back to pipenv?


Solution

  • Pipenv does a few different things, including dependency management and virtual environment management. In the context of a Heroku deployment it makes more sense to ask about dependencies than virtual environments. I think you're trying to switch from Pipenv to pip, not venv.

    Heroku uses Pipenv over pip if Pipenv configuration files are found. In this case, pip is skipped entirely.

    If you've already switched to pip locally

    pip doesn't use Pipfile or Pipfile.lock files at all.

    If you've already switched your local workflow to pip and already have an up-to-date requirements.txt, you can simply delete the Pipfile and Pipfile.lock, commit, and redeploy.

    If you don't have an up-to-date requirements.txt

    If you don't yet have a requirements.txt file, or if it is out of date, you can ask Pipenv to generate one for you from its lock file:

    pipenv requirements > requirements.txt
    

    By default, this will omit dev requirements. That's usually what you want when deploying to Heroku, but there are options documented in the linked page to handle dev requirements differently if you need to.

    Then proceed with deleting Pipenv config files, committing, and redeploying as above.