question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pip install block waiting forever for a keyring to unlock

See original GitHub issue

Environment

  • pip version: 20.0.2
  • Python version: 3.7.6
  • OS: Fedora

jaraco/keyring: v20.0.1 (automatically installed as PIP dependency)

Description

Pip block during install, waiting for a keyring to unlock (at least that’s my understanding)

Expected behavior

Pip install should proceed. I’m also confused about why pypi try to use any keyring to access pypi.org (See in the verbose output Getting credentials from keyring for https://pypi.org/simple).

How to Reproduce

pip install -vvv --no-deps --no-cache-dir -U importlib-metadata==1.1.3

Workaround Disable the keyring

PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
pip install -vvv --no-deps --no-cache-dir -U importlib-metadata==1.1.3

Likely related issue: https://github.com/pypa/pip/issues/6773

Output

Non-user install because user site-packages disabled
Created temporary directory: /tmp/pip-ephem-wheel-cache-710zevvx
Created temporary directory: /tmp/pip-req-tracker-1h_3qnhb
Initialized build tracking at /tmp/pip-req-tracker-1h_3qnhb
Created build tracker: /tmp/pip-req-tracker-1h_3qnhb
Entered build tracker: /tmp/pip-req-tracker-1h_3qnhb
Created temporary directory: /tmp/pip-install-arqqjx8s
1 location(s) to search for versions of importlib-metadata:
* https://pypi.org/simple/importlib-metadata/
Fetching project page and analyzing links: https://pypi.org/simple/importlib-metadata/
Getting page https://pypi.org/simple/importlib-metadata/
Found index url https://pypi.org/simple
Getting credentials from keyring for https://pypi.org/simple
^CCleaning up...
Removed build tracker: '/tmp/pip-req-tracker-1h_3qnhb'
ERROR: Operation cancelled by user
Exception information:
Traceback (most recent call last):
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/commands/install.py", line 331, in run
    resolver.resolve(requirement_set)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 281, in _get_abstract_dist_for
    req.populate_link(self.finder, upgrade_allowed, require_hashes)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/req/req_install.py", line 249, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/package_finder.py", line 899, in find_requirement
    req.name, specifier=req.specifier, hashes=hashes,
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/package_finder.py", line 881, in find_best_candidate
    candidates = self.find_all_candidates(project_name)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/package_finder.py", line 826, in find_all_candidates
    project_url, link_evaluator=link_evaluator,
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/package_finder.py", line 790, in process_project_url
    html_page = self._link_collector.fetch_page(project_url)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/collector.py", line 497, in fetch_page
    return _get_html_page(location, session=self.session)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/collector.py", line 337, in _get_html_page
    resp = _get_html_response(url, session=session)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/index/collector.py", line 143, in _get_html_response
    "Cache-Control": "max-age=0",
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/network/session.py", line 405, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_vendor/requests/models.py", line 317, in prepare
    self.prepare_auth(auth, url)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_vendor/requests/models.py", line 548, in prepare_auth
    r = auth(self)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/network/auth.py", line 202, in __call__
    url, username, password = self._get_url_and_credentials(req.url)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/network/auth.py", line 178, in _get_url_and_credentials
    username, password = self._get_new_credentials(original_url)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/network/auth.py", line 151, in _get_new_credentials
    get_keyring_auth(index_url, username) or
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/pip/_internal/network/auth.py", line 58, in get_keyring_auth
    cred = get_credential(url, username)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/keyring/core.py", line 74, in get_credential
    return _keyring_backend.get_credential(service_name, username)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/keyring/backends/SecretService.py", line 113, in get_credential
    collection = self.get_preferred_collection()
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/keyring/backends/SecretService.py", line 60, in get_preferred_collection
    collection.unlock()
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/secretstorage/collection.py", line 67, in unlock
    return unlock_objects(self.connection, [self.collection_path])
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/secretstorage/util.py", line 154, in unlock_objects
    dismissed, (signature, unlocked) = exec_prompt(connection, prompt)
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/secretstorage/util.py", line 140, in exec_prompt
    connection.recv_messages()
  File "/home/riquito/piggy_store/.env/lib64/python3.7/site-packages/jeepney/integrate/blocking.py", line 64, in recv_messages
    b = unwrap_read(self.sock.recv(4096))
KeyboardInterrupt

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

41reactions
JohnVillalovoscommented, Jun 12, 2020

Any solution to this? I have the same issue after a reboot on Ubuntu 18.04

Not a solution, but I as a workaround have added the following to my ~/.bashrc

# 1-May-2020: Fix for Keyring error with pip. Hopefully new pip will fix it
# soon https://github.com/pypa/pip/issues/7883
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
17reactions
JelteFcommented, Jun 1, 2021

I had the problem on WSL2 that DISPLAY was set, but there was no X server running. This caused pip to hang on the keyring. The fix for me was simply:

unset DISPLAY
Read more comments on GitHub >

github_iconTop Results From Across the Web

keyring · PyPI
The Python keyring library provides an easy way to access the system keyring service from python. It can be used in any application...
Read more >
Keyring is skipped due to an exception: Failed to unlock the ...
Totally > "WARNING: Keyring is skipped due to an exception: " should be harmless. It is, but asking me for a password I...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
o.lock to be removed" displayed by libtool in infinite loop (e.g. ... "sys-fs/cryptsetup for crypt-swap takes ages with openrc waiting for udev to...
Read more >
Stratis Storage
Use keyring , to make use of the mechanism that uses a key in the kernel keyring, which was introduced in Stratis 2.1.0....
Read more >
User Manual Ledger Nano S
Use the ​Ledger Manager​ to install apps on your device. ... Enter your PIN code to unlock the Ledger Nano S. ... While...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found