votes up 2


github stars 22232
Exception Class:

Raise code

    # 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.
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚢

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

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

Add a possible fix

Please authorize to post fix