47

Why is my pipenv stuck in the "Locking..." stage when installing [numpy|opencv|pandas]?

When running pipenv install pandas or pipenv update it hangs for a really long time with a message and loading screen that says it's still locking. Why? What do I need to do?

1
  • 1
    Add the --verbose flag to your commands and you can see where it's hanging Jul 22, 2022 at 22:10

5 Answers 5

74

Your package(s) are being installed and your wheel is being built

Perhaps better terminology to describe this state would be 'Building and Locking...' or something similar.

This is especially likely to happen if you're installing numpy, opencv, pandas, or other large packages.

What's going on in the background is that pipenv is downloading your package and maybe building the wheel.

The remedy in this case is often a strong dose of patience.

What is Locking?

To understand more about what "Locking" is in the pipenv context you can read more here: https://pipenv.kennethreitz.org/en/latest/basics/#pipenv-lock

$ pipenv lock is used to create a Pipfile.lock, which declares all dependencies (and sub-dependencies) of your project, their latest available versions, and the current hashes for the downloaded files. This ensures repeatable, and most importantly deterministic, builds.

However, there are times when it is not just a slow/large install, but is instead an issue with your Pipfile[.lock]. If you're fairly certain that this is the problem try pipenv lock --clear and rerun your pipenv install command, also check this thread for more information.

6
  • 6
    Thank! A great explanation so that we actually understand what is happening. Patience not a standard skill of the common developer.
    – Hailee
    Apr 24, 2020 at 12:22
  • 4
    Once I read your post I remembered that I am on a poor internet connection (vacation) and grabbing the packages may take a while.
    – Marc
    Oct 12, 2020 at 1:56
  • 4
    Try pipenv lock --clear --verbose so each package being deployed is shown at the standard output. This is useful to see where it is stalling Jul 22, 2022 at 21:50
  • 1
    Iuri Guilherme nailed it.
    – Rob
    Feb 19 at 16:08
  • I find it really weird not to display a download status when downloading a GB file. Thanks tho
    – DaWe
    Jun 5 at 17:02
7

I had this happen to me just now. Pipenv got stuck locking forever, 20+ minutes with no end in sight, and pipenv --rm didn't help.

In the end, the problem was that I had run pipenv install "boto3~=1.21.14" to upgrade boto3 from boto3 = "==1.17.105". But I had other conflicting requirements (in my case, botocore = "==1.20.105" and s3transfer = "==0.4.2") which are boto3 dependencies. The new version of boto3 required newer versions of these two packages, but the == requirements didn't allow that. Pipenv didn't explain this, and just spun "Locking…" forever.

So if you run into this, I would advise you to carefully look at your Pipenv packages, see if there are any obvious conflicts, and loosen or remove package requirements where possible.

In my case, I was able to just remove the s3transfer and botocore packages from the list entirely, and rely on boto3 to fetch the necessary versions.

1
  • 1
    This is a good catch. Maybe sharing the requirements file with pipenv developers would help them catch a bug, would that be possible?
    – Connor
    Mar 9, 2022 at 1:34
3

This is an open issue with pipenv https://github.com/pypa/pipenv/issues/3827

I suggest go back to pip

2
  • 1
    I still use pipenv with little problem. This happens occasionally, but now that it's clear what's going on it doesn't bother me. It's just annoying not to get any sort of feedback
    – Connor
    Aug 11, 2020 at 22:12
  • 2
    Note: the linked issue has been closed. This answer should be deleted.
    – psyFi
    Jul 28, 2021 at 17:15
2

For folks trying to use pipenv with an existing requirements.txt file in the working dir, you may find this Github post helpful.

Note: I also used pipenv --rm before attempting what I show.

HTH ;) P.S. Here's a shout out to Zebradil's script to create a requirements.txt, in case you're collaborating with others who don't use pipenv.

2
  • once you have edited the answer with a correct link. No need to put the link again in the comment. You may delete the comment. Feb 25, 2021 at 4:16
  • The link has been updated already with new information, but you may want to edit your answer to include it, there's a straightforward way to generate a requirements.txt which is pipenv -r lock 1> requirements.txt and in the next version it will be pipenv requirements 1> requirements.txt Aug 3, 2022 at 23:24
1

try doing pipenv --rm - removes virtual environment

then pipenv shell - this will again initiate virtual env

then pipenv install installs all the packages again

worked for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.