Skip to content
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

Poetry add tries to add incorrect version of library causing solver to fail #5453

Closed
3 tasks done
jgentil opened this issue Apr 14, 2022 · 5 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues

Comments

@jgentil
Copy link

jgentil commented Apr 14, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

I can't get Poetry to install the correct version of a package given the constraints in my pyproject.toml file, which is to keep it to supporting Python 3.7.x only.

When I run:

~\r\poetry_test_2> poetry add pyproj -vvv
Using virtualenv: C:\Users\Jon-Pierre.Gentil\AppData\Local\pypoetry\Cache\virtualenvs\poetry-test-2-IEFTtlYf-py3.7
PyPI: No release information found for pyproj-1.8.2, skipping
PyPI: No release information found for pyproj-1.8.3, skipping
PyPI: No release information found for pyproj-1.8.4, skipping
PyPI: No release information found for pyproj-1.8.5, skipping
PyPI: No release information found for pyproj-1.8.6, skipping
PyPI: No release information found for pyproj-1.8.7, skipping
PyPI: No release information found for pyproj-1.8.8, skipping
PyPI: No release information found for pyproj-1.8.9, skipping
PyPI: No release information found for pyproj-1.9.0, skipping
PyPI: No release information found for pyproj-1.9.2, skipping
PyPI: 34 packages found for pyproj *
Using version ^3.3.0 for pyproj

Updating dependencies
Resolving dependencies...
   1: fact: poetry-test-2 is 0.1.0
   1: derived: poetry-test-2
   1: fact: poetry-test-2 depends on pyproj (^3.3.0)
   1: selecting poetry-test-2 (0.1.0)
   1: derived: pyproj (>=3.3.0,<4.0.0)
PyPI: No release information found for pyproj-1.8.2, skipping
PyPI: No release information found for pyproj-1.8.3, skipping
PyPI: No release information found for pyproj-1.8.4, skipping
PyPI: No release information found for pyproj-1.8.5, skipping
PyPI: No release information found for pyproj-1.8.6, skipping
PyPI: No release information found for pyproj-1.8.7, skipping
PyPI: No release information found for pyproj-1.8.8, skipping
PyPI: No release information found for pyproj-1.8.9, skipping
PyPI: No release information found for pyproj-1.9.0, skipping
PyPI: No release information found for pyproj-1.9.2, skipping
PyPI: 1 packages found for pyproj >=3.3.0,<4.0.0
   1: fact: pyproj (3.3.0) requires Python >=3.8
   1: derived: not pyproj (==3.3.0)
   1: fact: no versions of pyproj match >3.3.0,<4.0.0
   1: conflict: no versions of pyproj match >3.3.0,<4.0.0
   1: !  pyproj (>3.3.0,<4.0.0) is partially satisfied by not  pyproj (3.3.0)
   1: ! which is caused by "pyproj (3.3.0) requires Python >=3.8"
   1: ! thus: pyproj is forbidden
   1: !  pyproj (>=3.3.0,<4.0.0) is satisfied by  pyproj (^3.3.0)
   1: ! which is caused by "poetry-test-2 depends on pyproj (^3.3.0)"
   1: ! thus: version solving failed
   1: Version solving took 0.009 seconds.
   1: Tried 1 solutions.

(( I truncated the stack trace as it's not particularly relevant but will add in a gist if needed ))

  SolverProblemError

  The current project's Python requirement (>=3.7,<3.8) is not compatible with some of the required packages Python requirement:
    - pyproj requires Python >=3.8, so it will not be satisfied for Python >=3.7,<3.8

  Because no versions of pyproj match >3.3.0,<4.0.0
   and pyproj (3.3.0) requires Python >=3.8, pyproj is forbidden.
  So, because poetry-test-2 depends on pyproj (^3.3.0), version solving failed.

  at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\puzzle\solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For pyproj, a possible solution would be to set the `python` property to "<empty>"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

Looking on PyPI at the pyproj package I see that 3.3.0 is only compatible with Python >=3.8. But 3.2.1 is compatible with Python >=3.7. Poetry seems to be installing the wrong version.

When using pip install pyproj it correctly identifies and installs pyproj 3.2.1 just fine.

~\r\poetry_test_2> c:\python\python37\python -m venv .venv

~\r\poetry_test_2> .venv\Scripts\activate.bat

[poetry_test_2] ~\r\poetry_test_2> pip install pyproj
Collecting pyproj
  Using cached pyproj-3.2.1-cp37-cp37m-win_amd64.whl (6.2 MB)
Collecting certifi
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Installing collected packages: certifi, pyproj
Successfully installed certifi-2021.10.8 pyproj-3.2.1
@jgentil jgentil added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 14, 2022
@Rafeqm
Copy link

Rafeqm commented Apr 16, 2022

Please read the error stack thoroughly:

   1: fact: poetry-test-2 depends on pyproj (^3.3.0)
(.................)
  SolverProblemError

  The current project's Python requirement (>=3.7,<3.8) is not compatible with some of the required packages Python requirement:
    - pyproj requires Python >=3.8, so it will not be satisfied for Python >=3.7,<3.8

  Because no versions of pyproj match >3.3.0,<4.0.0
   and pyproj (3.3.0) requires Python >=3.8, pyproj is forbidden.
  So, because poetry-test-2 depends on pyproj (^3.3.0), version solving failed.

You know what that means right? I think you can point where the problem lies for now and should close this issue.

@dimbleby
Copy link
Contributor

@Rafeqm I think you have misunderstood the report.

It is poetry that chooses to add pyproj ^3.3.0, the user has simply typed poetry add pyproj. The failure here is entirely of poetry's own making: it's not unreasonable to expect that poetry should add a version of pyproj that it can actually install.

Instead, it seems that poetry add always sets the requirement to be for the latest version of a dependency, regardless of whether that is compatible with other project constraints.

I doubt that this is something that's likely to change any time soon, unless someone gets motivated and submits a merge request. But it's a perfectly sensible thing to report.

@dimbleby
Copy link
Contributor

dimbleby commented Apr 18, 2022

Having said which, this duplicates issues as old as #707, #1589, #2171, ...

@jgentil
Copy link
Author

jgentil commented Apr 19, 2022

Ah, I tried looking for duplicates. It does look similar to those issues.

Maybe I'll make this issue a first contribution...

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

4 participants