Forums

pip install hangs

In a fresh Bash console, I am trying to use the command

pip install --user Django==3.1.9

This results in

Looking in links: /usr/share/pip-wheels
Collecting Django==3.1.9
  Using cached https://files.pythonhosted.org/packages/7a/4e/c6ec8e544eea36804c8795078df33aaca4932b7257188bd72124287372c4/Django-3.1.9-py3-none-any.whl

and then the command just hangs forever after.

Any ideas? I have alias pip=pip3, but and I've also tried pip3.8, but they all hang at the same place. I've also tried bypassing the cache and that didn't help either.

That's really strange! How long did you leave it for? Sometimes Django can be a bit slow to install, though I'd certainly expect it to take no more than a couple of minutes.

One thing you could perhaps try, if you haven't already, is to remove the directory .cache from your home directory -- that directory can always be rebuilt, and deleting it is a surefire way of bypassing the local cache -- better than using command-line options to do it.

After deleting.cache, .local/lib and .virtualenvs, and reinstalling everything with more patience than before, it's back working.

On the face of it, I guess I just didn't wait long enough. But I am starting to suspect something is wrong with the amount of time it's taking to do any pip operations. I went and tried to create a new virtualenv and installed Django in it, to see how long it would take. Here's what I got:

23:18 ~ $ date
Sat Jun 5 23:18:01 UTC 2021
23:18 ~ $ mkvirtualenv --python=python3.8 example
Running virtualenv with interpreter /usr/local/bin/python3.8
Already using interpreter /usr/local/bin/python3.8
Using base prefix '/usr'
New python executable in /home/vEnhance/.virtualenvs/example/bin/python3.8
Also creating executable in /home/vEnhance/.virtualenvs/example/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /home/vEnhance/.virtualenvs/example/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/vEnhance/.virtualenvs/example/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/vEnhance/.virtualenvs/example/bin/preactivate
virtualenvwrapper.user_scripts creating /home/vEnhance/.virtualenvs/example/bin/postactivate
virtualenvwrapper.user_scripts creating /home/vEnhance/.virtualenvs/example/bin/get_env_details
(example) 23:21 ~ $ date
Sat Jun 5 23:22:16 UTC 2021
(example) 23:22 ~ $ pip install django
Looking in links: /usr/share/pip-wheels
Collecting django
Downloading Django-3.2.4-py3-none-any.whl (7.9 MB)
|████████████████████████████████| 7.9 MB 1.4 MB/s
Collecting pytz
Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting sqlparse>=0.2.2
Using cached sqlparse-0.4.1-py3-none-any.whl (42 kB)
Collecting asgiref<4,>=3.3.2
Using cached asgiref-3.3.4-py3-none-any.whl (22 kB)
Installing collected packages: sqlparse, pytz, asgiref, django
Successfully installed asgiref-3.3.4 django-3.2.4 pytz-2021.1 sqlparse-0.4.1
(example) 23:28 ~ $ date
Sat Jun  5 23:28:38 UTC 2021

So it looks like creating a virtual environment is taking 2-3 minutes, and installing Django is taking a little over 6 minutes. Is that amount of time normal?

That is a bit slow, yes; disk access on PythonAnywhere will always be slower than on your own machine (because it's a networked file system rather than a local disk) but I'd expect more like 30s to create a virtualenv and a minute or so for Django, and that's what I saw when I tried just now.

I think that you may have just been unlucky there with the timing -- someone else on the same file server appears to have been doing something very disk-intensive at the time that you did your install.