Transient RuntimeError - unable to find installation candidates
- Poetry version: 1.5.1
- Python version: 3.10.6
- OS version and name: Ubuntu 22.04.01
- pyproject.toml: https://gist.github.com/larsyencken/2e2be54d124764b5a379afe673879ad8
- [x] I am on the latest stable Poetry version, installed using a recommended method.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] I have consulted the FAQ and blog for any relevant entries or release notes.
- [ ] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.- Did not do this, error is transient
Issue
We experience rolling, transient runtime errors in our build pipelines where poetry cannot find installation candidates for a package.
To combat this, we currently run poetry install --no-ansi || poetry install --no-ansi, since a second poetry run usually works fine. Still we experience situations where a third attempt is required for a successful build.
Here is an example, where the in the first failure it cannot find candidates for pyasn1, then in the retry it cannot find idna.
We would welcome an overall fix, or recommendations for our pipeline that could make this happen less often.
+ poetry env use python3.9
Creating virtualenv owid-datautils in /var/lib/buildkite-agent/builds/etl-build-1-6/our-world-in-data/owid-datautils-unit-tests/lib/datautils/.venv
Using virtualenv: /var/lib/buildkite-agent/builds/etl-build-1-6/our-world-in-data/owid-datautils-unit-tests/lib/datautils/.venv
+ poetry install --no-ansi
Installing dependencies from lock file
Package operations: 150 installs, 1 update, 0 removals
• Installing pyasn1 (0.5.0)
• Installing six (1.16.0)
RuntimeError
Unable to find installation candidates for pyasn1 (0.5.0)
at /usr/local/lib/poetry/venv/lib/python3.10/site-packages/poetry/installation/chooser.py:76 in choose_for
72│
73│ links.append(link)
74│
75│ if not links:
→ 76│ raise RuntimeError(f"Unable to find installation candidates for {package}")
77│
78│ # Get the best link
79│ chosen = max(links, key=lambda link: self._sort_key(package, link))
80│
+ poetry install --no-ansi
Installing dependencies from lock file
Package operations: 149 installs, 1 update, 0 removals
• Installing pyasn1 (0.5.0)
• Installing asttokens (2.2.1)
• Installing cachetools (5.3.1)
• Installing certifi (2023.5.7)
• Installing charset-normalizer (3.1.0)
• Installing executing (1.2.0)
• Installing idna (3.4)
• Installing jmespath (1.0.1)
• Installing markupsafe (2.1.3)
• Installing mdurl (0.1.2)
• Installing packaging (23.1)
• Installing parso (0.8.3)
• Installing protobuf (4.23.3)
• Installing ptyprocess (0.7.0)
• Installing pure-eval (0.2.2)
• Installing pyasn1-modules (0.3.0)
• Installing pycparser (2.21)
• Installing pyparsing (3.1.0)
• Installing python-dateutil (2.8.2)
• Installing rsa (4.9)
• Installing smmap (5.0.0)
• Installing traitlets (5.9.0)
• Installing urllib3 (1.26.16)
• Installing wcwidth (0.2.6)
• Installing zipp (3.15.0)
RuntimeError
Unable to find installation candidates for idna (3.4)
at /usr/local/lib/poetry/venv/lib/python3.10/site-packages/poetry/installation/chooser.py:76 in choose_for
72│
73│ links.append(link)
74│
75│ if not links:
→ 76│ raise RuntimeError(f"Unable to find installation candidates for {package}")
77│
78│ # Get the best link
79│ chosen = max(links, key=lambda link: self._sort_key(package, link))
80│
🚨 Error: The command exited with status 1
user command error: exit status 1
I have the same problem with the embreex package in macos ventura (apple m2) and poetry 1.5.1. Even running @larsyencken's poetry install --no-ansi || poetry install --no-ansi does not work. Installing the same in Ubuntu 20.04 does not have any problem.
I'm in MacOS Sonoma with Poetry 1.7.0 and having the same problem. Weirdly, my env is using python 3.9.18, but the error shows that is trying to use python 3.11:
poetry --version
Poetry (version 1.7.0)
python --version
Python 3.9.18
poetry run python --version
Python 3.9.18
poetry install --with dev,test,codestyle
Installing dependencies from lock file
Package operations: 90 installs, 0 updates, 0 removals
• Installing thinc (8.0.17): Failed
RuntimeError
Unable to find installation candidates for thinc (8.0.17)
at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/chooser.py:73 in choose_for
69│
70│ links.append(link)
71│
72│ if not links:
→ 73│ raise RuntimeError(f"Unable to find installation candidates for {package}")
74│
75│ # Get the best link
76│ chosen = max(links, key=lambda link: self._sort_key(package, link))
77│
Cannot install thinc.
We are facing a similar transient RuntimeError in our github actions. Occasionally runs will fail during poetry install step, and its not for the same packages, nor do we face the issue when running on the same environments locally (these are self-hosted runners)
$ poetry --version
Poetry (version 1.3.1)
$ python --version
Python 3.10.12
$ poetry run python --version
Python 3.10.12
CI logs can look like
...
Connection pool is full, discarding connection: pypi.org. Connection pool size: 10
RuntimeError
Unable to find installation candidates for matplotlib-inline (0.1.6)
at ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/chooser.py:105 in choose_for
101│
102│ links.append(link)
103│
104│ if not links:
→ 105│ raise RuntimeError(f"Unable to find installation candidates for {package}")
106│
107│ # Get the best link
108│ chosen = max(links, key=lambda link: self._sort_key(package, link))
109│
RuntimeError
Unable to find installation candidates for prometheus-client (0.18.0)
at ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/chooser.py:105 in choose_for
101│
102│ links.append(link)
103│
104│ if not links:
→ 105│ raise RuntimeError(f"Unable to find installation candidates for {package}")
106│
107│ # Get the best link
108│ chosen = max(links, key=lambda link: self._sort_key(package, link))
109│
added -vvv and got these logs:
• Installing referencing (0.30.2)
• Installing six (1.16.0)
Stack trace:
5 ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/executor.py:263 in _execute_operation
261│
262│ try:
→ 263│ result = self._do_execute_operation(operation)
264│ except EnvCommandError as e:
265│ if e.e.returncode == -2:
4 ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/executor.py:334 in _do_execute_operation
332│ return 0
333│
→ 334│ result: int = getattr(self, f"_execute_{method}")(operation)
335│
336│ if result != 0:
3 ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/executor.py:454 in _execute_install
452│
453│ def _execute_install(self, operation: Install | Update) -> int:
→ 454│ status_code = self._install(operation)
455│
456│ self._save_url_reference(operation)
2 ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/executor.py:488 in _install
486│ archive = self._download_link(operation, Link(package.source_url))
487│ else:
→ 488│ archive = self._download(operation)
489│
490│ operation_message = self.get_operation_message(operation)
1 ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/executor.py:626 in _download
624│
625│ def _download(self, operation: Install | Update) -> Path:
→ 626│ link = self._chooser.choose_for(operation.package)
627│
628│ if link.yanked:
RuntimeError
Unable to find installation candidates for six (1.16.0)
at ~/.local/.../python-3.10.12/lib/python3.10/site-packages/poetry/installation/chooser.py:105 in choose_for
101│
102│ links.append(link)
103│
104│ if not links:
→ 105│ raise RuntimeError(f"Unable to find installation candidates for {package}")
106│
107│ # Get the best link
108│ chosen = max(links, key=lambda link: self._sort_key(package, link))
109│
I had the same problem with private package, it ended up that I was building wheel for ARM that my local env is running on, but CI runs on x86_64 and it was missing binary for x86_64. After adding it to the published package I was able to successfully install it in CI. Maybe those packages that you're trying to install have the same problem - lacking of target architecture.
lxml 4.9.4 started causing consistent failures in my CI pipeline like this today, using Python 3.12 and Poetry 1.7.1. I've never seen this before, but install now reliably fails on my CI runner (with the only change to poetry.lock being updating from 4.9.3 to 4.9.4) and succeeds on my local machine. Both systems are x86_64 Linux.
When run with -vvv the output looks the same as https://github.com/python-poetry/poetry/issues/8139#issuecomment-1812982525; since Chooser.choose_for logs debug messages for ignored links and there aren't any Skipping wheel or Skipping distribution messages visible, it seems like either PyPI is failing to return any links for the package, or Poetry's debug logging is simply not working correctly.
Things that I believe this failure is not, which I've seen some discussions of similar issues suggest:
- Wrong credentials for a private repository: this project only uses PyPI
- Architecture mismatch: all testing has been on x86_64 Linux
- Bad cache:
poetry install --no-cachestill fails - Related to the presence of a terminal: still no debug logs if explicitly run with either
--ansior--no-ansi
Turns out my issue was an architecture mismatch, but seemingly caused by Poetry.lock not reflecting what was available on PyPI; I think because the lockfile was updated before the full set of wheels was available on PyPI. Updating the lockfile again added a bunch more wheels, including a manylinux_x86_64 wheel that was previously missing.
Seeing exactly the same thing happen with:
$ poetry --version
Poetry (version 1.8.2)
$ poetry run python --version
Python 3.10.12
Example:
Unable to find installation candidates for multidict (6.0.4)
at ~/.pyenv/versions/3.10.12/lib/python3.10/site-packages/poetry/installation/chooser.py:74 in choose_for
70│
71│ links.append(link)
72│
73│ if not links:
→ 74│ raise RuntimeError(f"Unable to find installation candidates for {package}")
75│
76│ # Get the best link
77│ chosen = max(links, key=lambda link: self._sort_key(package, link))
78│
Cannot install multidict.
However this is not the case when I run with the combination of poetry v1.5.1 and python 3.10.12
I believe I'm also experiencing this error within my ci tests -- link
Poetry fails to find an installation candidate on specific python versions, however I'm able to immediately ssh into the runner and pip install the dependency with no issues.
Same issue here: Unable to find installation candidates for onnxruntime (1.18.0). Weirdly it only happens when running within my Dockerfile. Is this an issue related to timeouts to the package sources during builds?
Facing the exact same error with nltk now, only within my Dockerfile. Is there any update on this?
***Update: Seemed to be fixed after updating nltk to 3.9.1
facing the same issue
same on mac m2
poetry --version
Poetry (version 1.7.1)
python --version
Python 3.11.9
Same issue on GitHub actions with onnx-runtime: https://github.com/aryn-ai/sycamore/actions/runs/13665326412/job/38205358284?pr=1208