Skip to content

Pip hangs after running any command (aside from --version, which is the only one that has worked for me) #9061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
msmur opened this issue Oct 27, 2020 · 5 comments

Comments

@msmur
Copy link

msmur commented Oct 27, 2020

Environment

  • pip version: 20.0.2
  • Python version: 3.8
  • Operating system: Ubuntu 20.04 running on WSL2

Description

Running any pip command (except pip --version) seems to cause it to hang until keyboard interrupt

Expected behavior

The command typed is meant to be executed

How to Reproduce

Note: I linked pip3 to run with the alias pip since I uninstalled python 2.7

  1. Get a fresh install of pip3 from 'sudo apt install python3-pip'
  2. Try to run any command aside from --version
  3. terminal hangs

Output
I am forced to keyboard interrupt

pip search asd
^CTraceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip3')()
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/search.py", line 18, in <module>
    from pip._internal.cli.req_command import SessionCommandMixin
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 19, in <module>
    from pip._internal.network.session import PipSession
  File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py", line 26, in <module>
    from pip._internal.network.auth import MultiDomainBasicAuth
  File "/usr/lib/python3/dist-packages/pip/_internal/network/auth.py", line 36, in <module>
    import keyring  # noqa
  File "/usr/lib/python3/dist-packages/keyring/__init__.py", line 3, in <module>
    from .core import (
  File "/usr/lib/python3/dist-packages/keyring/core.py", line 189, in <module>
    init_backend()
  File "/usr/lib/python3/dist-packages/keyring/core.py", line 93, in init_backend
    keyrings = filter(limit, backend.get_all_keyring())
  File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 21, in wrapper
    func.always_returns = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/keyring/backend.py", line 210, in get_all_keyring
    return list(rings)
  File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 31, in suppress_exceptions
    for callable in callables:
  File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
    return self.fget.__get__(None, owner)()
  File "/usr/lib/python3/dist-packages/keyring/backend.py", line 67, in viable
    cls.priority
  File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
    return self.fget.__get__(None, owner)()
  File "/usr/lib/python3/dist-packages/keyring/backends/kwallet.py", line 37, in priority
    bus = dbus.SessionBus(mainloop=DBusGMainLoop())
  File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 212, in __new__
    return Bus.__new__(cls, Bus.TYPE_SESSION, private=private,
  File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 102, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 124, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
  File "/usr/lib/python3/dist-packages/dbus/exceptions.py", line 47, in __init__
    def __init__(self, *args, **kwargs):
KeyboardInterrupt
@pradyunsg
Copy link
Member

You likely want to disable pip's use of the keyring -- see #8719 for context.

@msmur
Copy link
Author

msmur commented Oct 28, 2020

Thanks, managed to get it fixed by

export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring

and disabling the xsrv display line I had.

@msmur msmur closed this as completed Oct 28, 2020
@andreportela
Copy link

  1. I'm using pip and pipenv on a wsl2 environment (Ubuntu 20.04)
  2. It was working just fine with vscode remote
  3. Then I installed VcXsrv on Windows and got PyCharm to work on the WSL2 environment using this XServer and setting the DISPLAY variable on my .bashrc to be able to quickly launch PyCharm
  4. Boom! Both pip and pipenv stopped working. Any command from them (with the exception of --version) hang until keyboard interrupt
  5. Found this thread
  6. Disabled the DISPLAY variable for the X server on my .bashrc
  7. Boom! Fixed both pip and pipenv

@suhailxeaser
Copy link

I'm on windows so 'set' command worked for me instead of 'export'.

@TerminatedProcess
Copy link

  1. I'm using pip and pipenv on a wsl2 environment (Ubuntu 20.04)
  2. It was working just fine with vscode remote
  3. Then I installed VcXsrv on Windows and got PyCharm to work on the WSL2 environment using this XServer and setting the DISPLAY variable on my .bashrc to be able to quickly launch PyCharm
  4. Boom! Both pip and pipenv stopped working. Any command from them (with the exception of --version) hang until keyboard interrupt
  5. Found this thread
  6. Disabled the DISPLAY variable for the X server on my .bashrc
  7. Boom! Fixed both pip and pipenv

This was exactly it for me! I was trying to get tkinter to work in wsl and updated the DISPLAY variable. I never did get it working but forgot to remove my change. I just commented it out and pip is working again. Thanks a bunch!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants