25

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?

Waves
  • 773
  • 1
  • 5
  • 14
  • post contents of %HOME%\.pip\pip.log – Ayush Nov 25 '15 at 20:15
  • 4
    You should try `py -3 -m pip install some_package_you_want` – JBernardo Nov 26 '15 at 01:12
  • 17
    A 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 Answers7

35

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>)

Ben JW
  • 900
  • 9
  • 9
18

@JBernardo 's comment worked for me. Thanks!

python -m pip install some_package_you_want
Waves
  • 773
  • 1
  • 5
  • 14
15

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.

James M. Lay
  • 1,955
  • 21
  • 30
4

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

Mellester
  • 863
  • 6
  • 9
1

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.

dgrogan
  • 2,438
  • 1
  • 15
  • 21
0

Try using pip programmatically like shown below.

import pip

pip.main(['install', 'the_package_you_want_installed'])
Adi
  • 4,635
  • 1
  • 23
  • 37
-2

Mellester's solution worked for me.
I had trouble using pip list. The output would just hang until i started a Xserver.

KimN
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 03 '21 at 10:04
  • Please don't add "thank you" as an answer. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation), you will be able to [vote up questions and answers](https://stackoverflow.com/help/privileges/vote-up) that you found helpful. - [From Review](/review/late-answers/30247322) – Emi OB Nov 03 '21 at 11:31