Pip Install hangs

56,556

Solution 1

@JBernardo 's comment worked for me. Thanks!

python -m pip install some_package_you_want

Solution 2

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

Solution 3

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.

Solution 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

Solution 5

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.

Share:
56,556

Related videos on Youtube

Waves
Author by

Waves

Conventionally unconventional.

Updated on November 04, 2021

Comments

  • Waves
    Waves over 2 years

    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?

    • Ayush
      Ayush over 8 years
      post contents of %HOME%\.pip\pip.log
    • JBernardo
      JBernardo over 8 years
      You should try py -3 -m pip install some_package_you_want
    • martonbognar
      martonbognar about 6 years
      A note to future visitors of this thread: first check the output of pip -v install <package>, maybe it doesn't hang, just takes unusually long (but actually does stuff in the background) -- this was the case for me.
  • Mark Chackerian
    Mark Chackerian over 7 years
    and if you want more diagnostic cruft, python -v -m pip install some_package_you_want
  • pscheit
    pscheit almost 3 years
    uh yes, start your xserver!
  • pscheit
    pscheit almost 3 years
    try python -v -m pip install to see whats going on
  • James M. Lay
    James M. Lay almost 3 years
    @pscheit would that fix it?
  • pscheit
    pscheit almost 3 years
    @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)
  • flyingduck92
    flyingduck92 over 2 years
    do you mean like this: export DISPLAY= pip install django ?
  • chris
    chris over 2 years
    @flyingduck92 run the two commands separately. The export command just sets the DISPLAY environment variable to an empty string
  • Admin
    Admin over 2 years
    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.
  • Emi OB
    Emi OB over 2 years
    Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
  • Isaac
    Isaac over 2 years
    As another workaround, you can temporarily disable that prompt with unset DISPLAY.
  • James M. Lay
    James M. Lay over 2 years
    whoa, that's wayyy simpler.
  • rsmith54
    rsmith54 over 2 years
    this worked for me. Any idea why this works?
  • pax
    pax over 2 years
    This work for me too, but WHY???? I'm using X410 as an Xserver. Before that I tried Pip, PDM, Pyenv and Poetry with <command> list to list installed packages and took between 90 and 120 seconds
  • aurora
    aurora over 2 years
    that's a real WTF imo - it should prompt on the command-line instead of opening a window on some display. thanks for your help!
  • prehistoricpenguin
    prehistoricpenguin about 2 years
    unset DISPLAY is cool!