Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipenv stuck "⠋ Locking..."

Tags:

python

pip

pipenv

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?

like image 699
Connor Avatar asked Jun 04 '19 08:06

Connor


People also ask

How long should Pipenv lock take?

pipenv lock is still taking up to 30 minutes to complete for my medium-sized project.

What is locking in Pipenv?

$ 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.

What does Pipenv lock -- Clear do?

Note that pipenv lock --clear also locks the requirements, which is an undesired artifact if all you want is to clear the cache. For this purpose, use pipenv --clear as suggested below.


4 Answers

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.

like image 65
Connor Avatar answered Oct 19 '22 07:10

Connor


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

I suggest go back to pip

like image 41
Omkar Sheral Avatar answered Sep 19 '22 21:09

Omkar Sheral


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.

like image 4
Nick K9 Avatar answered Oct 19 '22 06:10

Nick K9


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.

like image 2
lino Avatar answered Oct 19 '22 07:10

lino