I currently have Python 3.5 on my Windows machine. I'm trying to install a Python package using the command "pip install"
but as soon as I hit enter nothing happens. The action hangs for such a long time and when I try to exit the command line, it freezes. How do I get pip install to work?
-
post contents of %HOME%\.pip\pip.log – Ayush Nov 25 '15 at 20:15
-
4You should try `py -3 -m pip install some_package_you_want` – JBernardo Nov 26 '15 at 01:12
-
21A note to future visitors of this thread: first check the output of `pip -v install
`, maybe it doesn't hang, just takes unusually long (but actually does stuff in the background) -- this was the case for me. – martonbognar Apr 11 '18 at 13:28
7 Answers
If you are you using WSL2, indeed it could be related to pip
trying to connect to an XServer. If so, clearing the DISPLAY
environment variable first before running it may help:
export DISPLAY=
pip install <packagename>
(Or, as a one-liner: DISPLAY= pip install <packagename>
)

- 1,370
- 1
- 10
- 11
-
-
1@flyingduck92 run the two commands separately. The export command just sets the DISPLAY environment variable to an empty string – chris Oct 13 '21 at 00:24
@JBernardo 's comment worked for me. Thanks!
python -m pip install some_package_you_want

- 903
- 1
- 6
- 14
-
8and if you want more diagnostic cruft, `python -v -m pip install some_package_you_want` – Mark Chackerian Oct 14 '16 at 18:39
-
-
If you're using Ubuntu via WSL2 on Windows, it might not work outside a virtualenv. python3 -v -m pip install ...
showed me that it was hanging on some OS X keychain import... Hopefully this helps someone else.

- 2,270
- 25
- 33
-
5
-
-
7@JamesM.Lay yep this was my issue. It was waiting for a connection to the x server (i guess to show the prompt for the keychain password) – pscheit Jul 17 '21 at 02:37
-
4As another workaround, you can temporarily disable that prompt with `unset DISPLAY`. – Isaac Dec 31 '21 at 12:03
-
-
1This work for me too, **but WHY????** I'm using X410 as an Xserver. Before that I tried `Pip`, `PDM`, `Pyenv` and Poetry with `
list` to list installed packages and took between 90 and 120 seconds – Jocer Jan 23 '22 at 22:36 -
1that's a real WTF imo - it should prompt on the command-line instead of opening a window on some display. thanks for your help! – aurora Jan 26 '22 at 11:03
-
I had to start 'Xlaunch' display server and it worked, according to a @pscheit it was waiting for a connection to x-server and launching one fixed it

- 922
- 7
- 9
pip install something
was hanging for me when I ssh'd into a linux machine and ran pip install
from that shell. Using -v
from above answers showed that this step was hanging
import 'keyring.backends.macOS' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3d15404d90>
This popped up a keyring authentication window on the linux machine's desktop, waiting for my password. Typing my password allowed this to progress.
I have no idea why a macOS package was being imported on a linux machine.

- 2,587
- 1
- 17
- 21
I don't know if this is connected to me using apple silicon
but suddenly pip install
stopped working. No error and nothing happened. Python reinstall didn't help, venv
reinitialization didn't help.
The only thing that helped was restarting my machine. Hope it helps someone.

- 4,417
- 10
- 73
- 132
Try using pip
programmatically like shown below.
import pip
pip.main(['install', 'the_package_you_want_installed'])

- 5,560
- 1
- 24
- 37