Search code examples
pythonpipconda

PIP very slow when using it in a conda environment


It has been some months since the problem appeared from nowhere, every time I install something using pip from a conda environment (fresh or old) it takes ages to start the process, i have been using -vvv for debugging the issue.

When i'm using the main conda environment the output look like the following:

Using pip 21.1.3 from /localdisk/<username>/anaconda3/lib/python3.9/site-packages/pip (python 3.9)
Non-user install because site-packages writeable
Created temporary directory: /tmp/pip-ephem-wheel-cache-79hpacew
Created temporary directory: /tmp/pip-req-tracker-2x18ocvp
...

while if I am in an environment the output looks like this:

Using pip 23.0.1 from /localdisk/lpuglia/anaconda3/envs/vpunn/lib/python3.8/site-packages/pip (python 3.8)
Non-user install because site-packages writeable
[*** HERE PIP HANGS FOR ABOUT 2 MINUTES ***]
Created temporary directory: /tmp/pip-build-tracker-xb9h_yb9
Initialized build tracking at /tmp/pip-build-tracker-xb9h_yb9
...

besides the obvious difference in version between the two pips, I really can't say what is the problem. Using -vvv doesn't shed any light on the source of the problem. I was expecting some hanging due to network problems but from the output it looks like that the hang happens before creating a folder.

Interestingly enough, if I call pip again just after it finishes (few seconds) it doesn't hang for 2 minutes. This time window is very small, waiting for 10 seconds will force another hang on the next pip installation.

I'm out of ideas on how to debug this issue, if anyone could suggest a way to understand better the problem or a solution it would be ideal.


Solution

  • To answer my own question: it looks like that synchronizing pip version across base environment and the working environment solves the problem. Not sure why this happens, but any other answer with a better explanation will be accepted as the correct one.

    EDIT:

    We finally figured an explanation, it looks like that pip checks the content of /etc/ before doing anything. For some reason, our machine had broken link to unavailable nfs partition in the /etc/ folder. We just had to remove the broken link and now pip is not hanging anymore. To check if this is your scenario try to ls /etc, if it hangs, so pip will.