Pip Install hangs

Question:

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?

Asked By: Waves

||

Answers:

Try using pip programmatically like shown below.

import pip

pip.main(['install', 'the_package_you_want_installed'])
Answered By: Adi

@JBernardo ‘s comment worked for me. Thanks!

python -m pip install some_package_you_want
Answered By: Waves

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.

Answered By: James M. Lay

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

Answered By: Mellester

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

Answered By: Ben JW

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.

Answered By: dgrogan

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

Answered By: KimN

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.

Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.