python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.4k stars 2.27k forks source link

Bug or messaging problem? #2328

Open drcongo opened 4 years ago

drcongo commented 4 years ago

Issue

I'm not sure if this is a bug or a problem with the messaging in Poetry, but it's something I see a lot, and it's rather hard to search for in the issues so sorry if it's a dupe. Here's the problem...

I have a pyproject.toml that includes this in dev dev dependencies...

[tool.poetry.dev-dependencies]
faker = "*"
mixer = "*"

I discover that mixer is pretty much abandoned and has a bug that breaks my tests, but all my tests depend on it, so I fork the repo and try to switch to installing from my fork by editing the pyproject.toml

[tool.poetry.dev-dependencies]
faker = "*"
mixer = {path = "src/mixer/"}

I then run poetry install and I get this output...

[SolverProblemError]
Because no versions of mixer match !=6.1.3
 and mixer (6.1.3) depends on Faker (0.9.1), every version of mixer requires Faker (0.9.1).
So, because no versions of faker match 0.9.1
 and myproject depends on mixer (*), version solving failed.

This is telling me that there is no version 0.9.1 of faker. So, I check the faker release history and there it is, 0.9.1

Then I remember how often Poetry does this to me, and instead of editing the pyproject.toml I run poetry add faker="0.9.1" and get this output...

Updating dependencies
Resolving dependencies... (4.7s)

Writing lock file

Package operations: 0 installs, 3 updates, 1 removal

  - Updating text-unidecode (1.3 -> 1.2)
  - Updating faker (4.0.3 -> 0.9.1)
  - Updating mixer (5.5.7 -> 6.1.3 src/mixer)
  - Removing fake-factory (0.5.7)

So, if Faker 0.9.1 definitely exists, and poetry is perfectly able to resolve the dependencies, why does it tell me that it can't in the first message?

drcongo commented 4 years ago

An even simpler example has just happened to me now. For some reason Poetry chokes when I'm installing gevent 1.5.0 on my servers, so I needed to pin it at 1.4.0. I added gevent = "1.4.0" to the pyproject.toml and ran poetry install

$ poetry install
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

[SolverProblemError]
Because myproject depends on gevent (1.4.0) which doesn't match any versions, version solving failed.

Took it out of the pyproject.toml and added it via the cli...

$ poetry add gevent="1.4.0"
Skipping virtualenv creation, as specified in config file.

Updating dependencies
Resolving dependencies... (52.9s)

Writing lock file

Package operations: 0 installs, 1 update, 0 removals

  - Updating gevent (1.5.0 -> 1.4.0)

Worked perfectly.

ddobson commented 3 years ago

I ran into a similar issue. I also was trying to install a local project with its own dependencies (A), into another local project (B), using the path specification. Even though the new dependency causing an error in Project B had been committed to the lock file in Project A, I still needed to run a poetry lock in Project B to get things working. Hopefully this helps anyone that stumbles on this issue in the future.

finswimmer commented 3 years ago

Hello @ddobson,

can you please provide a minimal example to reproduce your problem?

fin swimmer

tim-fiola commented 3 years ago

Here's my recent example of this exact problem

(redacted-visualization-plugin-hUDdVxob-py3.8) redacted-visualization-plugin/redacted-plugin-redacted-visualization-plugin % poetry install                      (dev)redacted-plugin-redacted-visualization-plugin
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

  SolverProblemError

  Because redacted-visualization-plugin depends on dash-cytoscape (0.3.0) which doesn't match any versions, version solving failed.

  at ~/.poetry/lib/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
(redacted-visualization-plugin-hUDdVxob-py3.8) redacted-visualization-plugin/redacted-plugin-redacted-visualization-plugin % poetry add dash-cytoscape="^0.3.0"

Updating dependencies
Resolving dependencies... (30.0s)

Writing lock file

Package operations: 62 installs, 0 updates, 0 removals

  • Installing six (1.16.0)
  • Installing markupsafe (2.0.1)
  • Installing asgiref (3.4.1)
  • Installing click (7.1.2)
  • Installing itsdangerous (1.1.0)
  • Installing jinja2 (2.11.3)
  • Installing lazy-object-proxy (1.6.0)
  • Installing pytz (2021.1)
  • Installing sqlparse (0.4.1)
  • Installing werkzeug (1.0.1)
  • Installing wrapt (1.12.1)
  • Installing astroid (2.7.2): Pending...
  • Installing astroid (2.7.2): Downloading... 0%
  • Installing astroid (2.7.2): Downloading... 10%
  • Installing astroid (2.7.2): Downloading... 20%
  • Installing astroid (2.7.2): Downloading... 100%
  • Installing astroid (2.7.2): Downloading... 100%
  • Installing astroid (2.7.2): Installing...
  • Installing astroid (2.7.2)
  • Installing brotli (1.0.9)
  • Installing django (3.1.13)
  • Installing flask (1.1.4)
  • Installing isort (5.8.0)
  • Installing joblib (1.0.1)
  • Installing mccabe (0.6.1)
  • Installing platformdirs (2.2.0)
  • Installing pyyaml (5.4.1)
  • Installing regex (2021.8.21)
  • Installing smmap (4.0.0)
  • Installing tenacity (8.0.1)
  • Installing toml (0.10.2)
  • Installing tqdm (4.62.2)
  • Installing dash-core-components (1.17.1)
  • Installing dash-html-components (1.1.4)
  • Installing dash-table (4.12.0)
  • Installing flask-compress (1.10.1)
  • Installing future (0.18.2)
  • Installing gitdb (4.0.7)
  • Installing nltk (3.6.2)
  • Installing pbr (5.6.0)
  • Installing plotly (5.2.2)
  • Installing pylint (2.10.2)
  • Installing tornado (6.1)
  • Installing typing-extensions (3.10.0.0)
  • Installing appdirs (1.4.4): Pending...
  • Installing appdirs (1.4.4): Installing...
  • Installing appdirs (1.4.4)
  • Installing dash (1.21.0)
  • Installing gitpython (3.1.20)
  • Installing livereload (2.6.3)
  • Installing lunr (0.5.8)
  • Installing markdown (3.3.4)
  • Installing mypy-extensions (0.4.3)
  • Installing pathspec (0.9.0)
  • Installing pycodestyle (2.7.0)
  • Installing pyflakes (2.3.1)
  • Installing pylint-plugin-utils (0.6)
  • Installing snowballstemmer (2.1.0)
  • Installing stevedore (3.4.0)
  • Installing typed-ast (1.4.3)
  • Installing bandit (1.7.0)
  • Installing black (20.8b1)
  • Installing coverage (5.5)
  • Installing dash-cytoscape (0.3.0)
  • Installing django-debug-toolbar (3.2.2)
  • Installing flake8 (3.9.2)
  • Installing invoke (1.6.0)
  • Installing mkdocs (1.1.2)
  • Installing pydocstyle (6.1.1)
  • Installing pylint-django (2.4.4)
  • Installing yamllint (1.26.3)
(redacted-visualization-plugin-hUDdVxob-py3.8) redacted-visualization-plugin/redacted-plugin-redacted-visualization-plugin % poetry add dash="^1.21.0"         

Updating dependencies
Resolving dependencies... (0.7s)

Writing lock file

No dependencies to install or update
(redacted-visualization-plugin-hUDdVxob-py3.8) redacted-visualization-plugin/redacted-plugin-redacted-visualization-plugin % poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: redacted-visualization-plugin (0.1.0)
(redacted-visualization-plugin-hUDdVxob-py3.8) redacted-visualization-plugin/redacted-plugin-redacted-visualization-plugin %    
jjorissen52 commented 2 years ago

We see similar errors thrown intermittently during CI/CD, but right now one of our developers is consistently unable to run poetry install because it fails with the message Because my-package depends on pydantic (^1.8.2) which doesn't match any versions, version solving failed. This package version does exist and can be resolved on other machines. We cannot provide a minimum reproducible example because we don't know what causes it.

silverrainb commented 2 years ago

Experiencing the same. I simply initialized poetry and specified flask version with the latest and got the similar error. Happening for redis as well.

  Because <> depends on Flask (>=2.0.2) which doesn't match any versions, version solving failed.

  at ~/Library/Application Support/pypoetry/venv/lib/python3.9/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
radoering commented 2 years ago

In some comments I read that the issue occurs when running poetry install after manually editing pyproject.toml. At least in some cases, the issue may be that poetry tries to install dependencies from poetry.lock (if existing). However, after manually editing pyproject.toml it may be insconsistent with poetry.lock. In this case, poetry lock [--no-update] should be called before running poetry install. In contrast, when running poetry add, the lock file is updated automatically. Alternatively, poetry update can be used to lock and install in one step.