pip icon indicating copy to clipboard operation
pip copied to clipboard

EOFError when prompting for index username and password

Open EpicWink opened this issue 3 years ago • 1 comments

Description

When installing from a private, password-protected (authenticating with HTTP BasicAuth) package index server, the subprocess to install build dependencies fails with an EOFError.

Everything works fine when keyring is installed (as I have the private index's password in my keyring).

When using Pip 22.0.4, it seems a ZipApp was used, as the traceback showed the used pip was located in /tmp/pip-standalone-pip-qari24rb/__env_pip__.zip/. The final two lines of the output (entering username and password) didn't occur.

Possibly related:

  • #2920
  • #10665
  • #10806
  • #11020

Expected behavior

pip install all packages successfully

pip version

22.2.2 (also tested with 22.0.2)

Python version

Python 3.10.4 (distro-managed)

OS

Ubuntu 22.04.1

How to Reproduce

  1. Create a new virtual environment with standard-library venv
  2. Install packages from private index (either as main or extra index)

Output

click to expand
$ pip install -e . --extra-index-url https://pypi.example.com/
Looking in indexes: https://pypi.org/simple, https://pypi.example.com/
Obtaining file:///home/me/src/my-package
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 2
  ╰─> [59 lines of output]
      Looking in indexes: https://pypi.org/simple, https://pypi.example.com/
      User for pypi.example.com: ERROR: Exception:
      Traceback (most recent call last):
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
          status = run_func(*args)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
          return func(self, options, args)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 369, in run
          requirement_set = resolver.resolve(
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
          result = self._result = resolver.resolve(
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
          state = resolution.resolve(requirements, max_rounds=max_rounds)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
          self._add_to_criteria(self.state.criteria, r, parent=None)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
          if not criterion.candidates:
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
          return bool(self._sequence)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
          return any(self)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
          return (c for c in iterator if id(c) not in self._incompatible_ids)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 44, in _iter_built
          for version, func in infos:
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 279, in iter_index_candidate_infos
          result = self._finder.find_best_candidate(
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/package_finder.py", line 889, in find_best_candidate
          candidates = self.find_all_candidates(project_name)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/package_finder.py", line 830, in find_all_candidates
          page_candidates = list(page_candidates_it)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/sources.py", line 134, in page_candidates
          yield from self._candidates_from_page(self._link)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/package_finder.py", line 790, in process_project_url
          index_response = self._link_collector.fetch_response(project_url)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/collector.py", line 577, in fetch_response
          return _get_index_content(location, session=self.session)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/collector.py", line 481, in _get_index_content
          resp = _get_simple_response(url, session=session)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/index/collector.py", line 138, in _get_simple_response
          resp = session.get(
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/requests/sessions.py", line 600, in get
          return self.request("GET", url, **kwargs)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/network/session.py", line 518, in request
          return super().request(method, url, *args, **kwargs)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/requests/sessions.py", line 587, in request
          resp = self.send(prep, **send_kwargs)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/requests/sessions.py", line 708, in send
          r = dispatch_hook("response", hooks, r, **kwargs)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_vendor/requests/hooks.py", line 30, in dispatch_hook
          _hook_data = hook(hook_data, **kwargs)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/network/auth.py", line 270, in handle_401
          username, password, save = self._prompt_for_password(parsed.netloc)
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/network/auth.py", line 233, in _prompt_for_password
          username = ask_input(f"User for {netloc}: ")
        File "/home/me/src/my-package/.venv/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 204, in ask_input
          return input(message)
      EOFError: EOF when reading a line
      User for pypi.example.com: WARNING: There was an error checking the latest version of pip.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 2
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
User for pypi.example.com: SPAM-USER
Password:

Note: final two lines are after pip had already failed

Code of Conduct

EpicWink avatar Aug 19 '22 04:08 EpicWink

Actually, I think this does duplicate #10665

EpicWink avatar Aug 19 '22 04:08 EpicWink