pip: Infinite loop on pip when lockfile can't acquire a lock
- Pip version: 8.0.3
- Python version: 3.5.1
- Operating System: Windows 10x64
Description:
- running
pip list -o
with Sphinx 1.3.6 (the current version) causes pip to go into some sort of infinite loop. Nothing is printed to the console.
- trying to install Sphinx 1.3.6 from PyPI start an infinite loop and the package is never installed.
- tyring to update Sphinx (
pip install sphinx -U
) starts an infinite loop and nothing seems to happen
- Sphinx can be installed from a downloaded wheel (from PyPI) without issue.
- other pip commands seem to work without issue.
- the issue doesn’t seem to be limited to Sphinx 1.3.6, but I can’t seem to narrow that down any further
What I’ve run:

About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 26 (9 by maintainers)
Commits related to this issue
Deleting
~/.cache/pip
resolved this issue for me. I had previously tried several different versions/venvs ofpython3.[4,5,6]
and all blocked onmkdirlock
.The bug I think is rather that some earlier usage of pip leaves a lock-file in place? (
pip
exits uncleanly elsewhere?)@MinchinWeb Does adding
--no-cache-dir
topip list -o --no-cache-dir
avoid the issue ?We’ve fixed this via #4766.
Happened to me just now with 9.0.1 on Mac OS X.
Not sure where the lock file is though to remove it. 😦 (Edit: Removing
~/Library/Caches/pip
worked.)Running with verbose mode on (in a new virtualenv) provides the following:
[ it stalls here, so I end it with CTRL+C ]
So if I read that right, it can’t create the lock file because one already exists, so it’s waiting for the lock folder to disappear (probably to try again). My guess is this is the infinite loop it’s stuck in.
Deleting the lock folder in question doesn’t seem to help running processes, but does allow a new process to install Sphinx.
Update: Turns out there was another rogue lock folder (
f9daaa0b90d3f26ba99d3a4afed1be31abd9eddd0acd969de27db871.lock
). Deleting that allows running processes to keep going and finish as expected.Does there need to be a limit applied to how long it will wait? Should some procedure be put in place to clear out old lock folders? Or at least tell the user which lock folder is holding up pip? As a minimum, if you break out of the pip (without using the verbose options), it should tell you what lock folder it’s hung up on.
It’s a little bit amazing to see the winding, 3 year road from bug report to fix. Keep up the good work!
I had the same issue so to bypass it I had to delete the cache .lock of pip as @MinchinWeb has said or I had to put a return after line 56 in mkdirlockfile.py to avoid the time.sleep function