votes up 1

Pipfile.lock

Package:
pipenv
github stars 21874
Exception Class:
exceptions.LockfileNotFound

Raise code

    sequential=False,
    pypi_mirror=None,
    system=False,
    deploy=False,
):
    # The lock file needs to exist because sync won't write to it.
    if not project.lockfile_exists:
        raise exceptions.LockfileNotFound("Pipfile.lock")

    # Ensure that virtualenv is available if not system.
    ensure_project(
        three=three,
        python=python,
        validate=False,
        deploy=deploy,

Ways to fix

votes up 0 votes down

When you work with pipenv, both Pipfile and Pipfile.lock should exsit in a directory where you execute pipenv sync command.

Let's create an empty project:

mkdir tmp
cd tmp/
pipenv --python 3.6

Lets check all files which were created:

$ ls
Pipfile

So if there were no packages installed, only one Pipfile exists which has meta ifo about a project only:

If you will try to run pipenv sync at this point, you will already see an exception:

ERROR: Pipfile.lock not found! You need to run $ pipenv lock before you can continue.

Actually, the sync command installs all locked packages. But now we have no packages at all so exception makes sense! Let's install the first package into our pipenv:

pipenv install requests

Now we have two files:

$ ls
PipfileΒ  Pipfile.lock

And if you will run pipenv sync, the request package will be just reinstalled successfully:

$ pipenv sync
Installing dependencies from Pipfile.lock (b14837)...
Β  🐍  Β β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 0/0 β€” 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!

But once you remove Pipfile.lock file with:

rm Pipfile.lock

and then try sync again, an exception will return,

To fix it, if lock file was deleted, just run:

pipenv install

So, main reasons why the exception happens:

  1. You or repository creator did not commit Pipfile.lock to the repository
  2. You or some removed Pipfile.lock
  3. You are trying to run sync command on a fresh project without packages which makes no sense

In the last case, you might need to read basics about how to use pipenv

Jun 03, 2021 ivictbor answer
ivictbor 13

Add a possible fix

Please authorize to post fix