poetry: PyQt5 install failing via Poetry [NEW BUG]

  • Poetry version: 1.6.1
  • Python version: 3.11.1
  • OS version and name: Ubuntu 22.04
  • pyproject.toml: N/A
  • [ 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.
  • [x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

This morning Riverbank pushed out a new version of pyqt5 (5.15.10) and pyqt5-qt5 (5.15.11) to pypi and it seems to have messed things up with poetry dependency resolution. But basically now the situation is no matter if you try to install pyqt5 5.15.9 (most recent version till today) or 5.15.10, poetry considers that this depends strictly upon pyqt5-qt5 3.15.11, but yet it doesn’t seem to exist right now from poetry’s point of view. Specifically the error is:

 Unable to find installation candidates for pyqt5-qt5 (5.15.11)

  at ~/.local/share/pypoetry/venv/lib/python3.10/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))

It is clearly on pypi though: https://pypi.org/project/PyQt5-Qt5/#history

I have created a minimal script that you should be able to reproduce this with on any linux system w/ poetry installed (pyenv helps if you want to match my exact config), so long as the issue doesn’t fix itself due to things automatically updating (which I’m hoping for):

#!/bin/bash
tmp_dir=$(mktemp -d -t poetry_issue-XXXX)
cd "$tmp_dir"

if command -v pyenv &> /dev/null; then
    pyenv install 3.11.1
    pyenv local 3.11.1
    poetry init --no-interaction --python 3.11.1
else
    poetry init --no-interaction --python $(python -V 2>&1 | awk '{print $2}')
fi

# Poetry
{
    poetry -vvv add pyqt5==5.15.9 2>&1
    poetry -vvv install 2>&1
} > poetry_traceback.txt

# Pip
python -m venv traditional_venv
source traditional_venv/bin/activate

{
    python -m pip install PyQt5==5.15.9 -v 2>&1
} > pip_output.txt

deactivate

# Cleanup
rm .python-version
cd -
mv "$tmp_dir/poetry_traceback.txt" ./poetry_traceback.txt
mv "$tmp_dir/pip_output.txt" ./pip_output.txt
mv "$tmp_dir/poetry.lock" ./poetry.lock
rm -rf "$tmp_dir"

Pip was able to install it, but it doesn’t seem to try to install 5.15.11 and instead uses 5.15.2. Therefore, there may be an issue with Riverbank for having uploaded a bad version, but we should still be able to fallback to 5.15.2 as pip does.

Outputs of the poetry and pip (note that the pip install is succesful):

Poetry add/install output for pyqt5 3.15.9: https://gist.github.com/jordantgh/78dd541597048e89dda16647431f2268 Pip install output for the same: https://gist.github.com/jordantgh/f8fb87bc348fe3cb5237f2d819f2135f

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 4
  • Comments: 22 (7 by maintainers)

Commits related to this issue

Most upvoted comments

well, i’m just starting to evaluate poetry and i got hit by this, too.

i can only confirm @jordantgh 's confusion. as someone who’s trying to find a “smarter” tool than plain pip, i was very surprised by pip being actually smarter than poetry in this specific case. having to specify a version of sub-dependency by hand is hardly a “smart” solution.

anyway, i still don’t see the “cross-platform solution” you’re talking about. would the very same command fail on macos?

still not a bug, please close

Specifying versions in pyproject.toml did the trick for me. Not exactly sure why or how though. Without explicitly stating the pyqt5-qt5 module version, poetry tries to install the 5.15.12 version and fails.

pyqt5 = "=5.15.10"   
pyqt5-qt5 = "=5.15.2"

Specifying it manually does indeed short circuit the dependency lookup and fix the issue for me. However, while I guess it may be not poetry’s fault (I do not know how your dependency resolution works), I certainly would have thought failing to install pyqt5 because you are retrieving the wrong (macOS-specific) dependency would at least be considered unintended behaviour. Pip does not have this issue, somehow it is able to retrieve the correct one.

pip is solving “install something on the current platform”, poetry is solving “build a cross-platform solution” - these are very different things and the comparison is not useful.

One could imagine that in order to meet its cross-platform promise poetry could examine the available distributions for a given version and verify that coverage was complete. However that would be tedious at best - and likely counterproductive, because I bet lots of popular packages don’t ship distributions for all possible platforms…

So instead poetry takes the view that when such things happen you should go to pyqt5 (or whoever) and ask them to release the missing packages, please.