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

Cannot "poetry add matplotlib", possible bug in dependency resolution #580

Closed
3 tasks done
mbello opened this issue Oct 30, 2018 · 8 comments
Closed
3 tasks done
Labels
area/solver Related to the dependency resolver kind/feature Feature requests/implementations

Comments

@mbello
Copy link

mbello commented Oct 30, 2018

  • 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).
  • OS version and name: Ubuntu 18.04
  • Poetry version: 0.12.4
  • Contents of your pyproject.toml file:
    [tool.poetry]
    name = "test"
    version = "0.1.0"
    description = ""
    authors = ["mbello mbello@users.noreply.github.com"]

[tool.poetry.dependencies]
python = "*"

[tool.poetry.dev-dependencies]
pytest = "^3.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

Matplotlib requires python >=3.5
I am on python 3.6.6 and poetry does not allow me to install matplotlib.
The command poetry run pip install matplotlib did work as a workaround.

Steps to reproduce

$ rm -Rf test
$ poetry new test
Created package test in test
$ cd test
$ poetry --version
Poetry 0.12.4
$ python --version
Python 3.6.6
$ poetry run python --version
Creating virtualenv test-py3.6 in /home/mbello/PycharmProjects/test/.venv
Python 3.6.6
$ poetry -vvv add matplotlib
Using virtualenv: /home/mbello/PycharmProjects/test/.venv
PyPI: No release information found for matplotlib-0.63.0, skipping
PyPI: No release information found for matplotlib-0.64, skipping
PyPI: No release information found for matplotlib-0.65, skipping
PyPI: No release information found for matplotlib-0.70, skipping
PyPI: No release information found for matplotlib-0.71, skipping
PyPI: No release information found for matplotlib-0.83.2, skipping
PyPI: No release information found for matplotlib-0.85, skipping
PyPI: No release information found for matplotlib-0.87.1, skipping
PyPI: No release information found for matplotlib-0.87.2, skipping
PyPI: No release information found for matplotlib-0.87.3, skipping
PyPI: No release information found for matplotlib-0.87.4, skipping
PyPI: No release information found for matplotlib-0.87.5, skipping
PyPI: No release information found for matplotlib-0.87.6, skipping
PyPI: No release information found for matplotlib-0.87.7, skipping
PyPI: No release information found for matplotlib-0.90.0, skipping
PyPI: No release information found for matplotlib-0.90.1, skipping
PyPI: No release information found for matplotlib-0.91.2, skipping
PyPI: No release information found for matplotlib-0.91.3, skipping
PyPI: No release information found for matplotlib-0.91.4, skipping
PyPI: No release information found for matplotlib-0.98.0, skipping
PyPI: No release information found for matplotlib-0.98.1, skipping
PyPI: No release information found for matplotlib-0.98.3, skipping
PyPI: No release information found for matplotlib-0.98.5.1, skipping
PyPI: No release information found for matplotlib-0.98.5.3, skipping
PyPI: No release information found for matplotlib-0.99.0, skipping
PyPI: No release information found for matplotlib-0.99.1, skipping
PyPI: No release information found for matplotlib-0.99.3, skipping
PyPI: No release information found for matplotlib-1.0.0, skipping
PyPI: 41 packages found for matplotlib *
Using version ^3.0 for matplotlib

Updating dependencies
Resolving dependencies...
1: fact: test is 0.1.0
1: derived: test
1: fact: test depends on matplotlib (^3.0)
1: fact: test depends on pytest (^3.0)
1: selecting test (0.1.0)
1: derived: pytest (^3.0)
1: derived: matplotlib (^3.0)
PyPI: 42 packages found for pytest >=3.0,<4.0
PyPI: No release information found for matplotlib-0.63.0, skipping
PyPI: No release information found for matplotlib-0.64, skipping
PyPI: No release information found for matplotlib-0.65, skipping
PyPI: No release information found for matplotlib-0.70, skipping
PyPI: No release information found for matplotlib-0.71, skipping
PyPI: No release information found for matplotlib-0.83.2, skipping
PyPI: No release information found for matplotlib-0.85, skipping
PyPI: No release information found for matplotlib-0.87.1, skipping
PyPI: No release information found for matplotlib-0.87.2, skipping
PyPI: No release information found for matplotlib-0.87.3, skipping
PyPI: No release information found for matplotlib-0.87.4, skipping
PyPI: No release information found for matplotlib-0.87.5, skipping
PyPI: No release information found for matplotlib-0.87.6, skipping
PyPI: No release information found for matplotlib-0.87.7, skipping
PyPI: No release information found for matplotlib-0.90.0, skipping
PyPI: No release information found for matplotlib-0.90.1, skipping
PyPI: No release information found for matplotlib-0.91.2, skipping
PyPI: No release information found for matplotlib-0.91.3, skipping
PyPI: No release information found for matplotlib-0.91.4, skipping
PyPI: No release information found for matplotlib-0.98.0, skipping
PyPI: No release information found for matplotlib-0.98.1, skipping
PyPI: No release information found for matplotlib-0.98.3, skipping
PyPI: No release information found for matplotlib-0.98.5.1, skipping
PyPI: No release information found for matplotlib-0.98.5.3, skipping
PyPI: No release information found for matplotlib-0.99.0, skipping
PyPI: No release information found for matplotlib-0.99.1, skipping
PyPI: No release information found for matplotlib-0.99.3, skipping
PyPI: No release information found for matplotlib-1.0.0, skipping
PyPI: 2 packages found for matplotlib >=3.0,<4.0
1: fact: matplotlib (3.0.1) requires Python >=3.5
1: derived: not matplotlib (3.0.1)
1: fact: matplotlib (3.0.0) requires Python >=3.5
1: derived: not matplotlib (3.0.0)
1: fact: no versions of matplotlib match >3.0,<3.0.1 || >3.0.1,<4.0
1: conflict: no versions of matplotlib match >3.0,<3.0.1 || >3.0.1,<4.0
1: ! matplotlib (>3.0,<3.0.1 || >3.0.1,<4.0) is partially satisfied by not matplotlib (3.0.0)
1: ! which is caused by "matplotlib (3.0.0) requires Python >=3.5"
1: ! thus: matplotlib is forbidden
1: ! matplotlib (>=3.0,<3.0.1 || >3.0.1,<4.0) is partially satisfied by not matplotlib (3.0.1)
1: ! which is caused by "matplotlib (3.0.1) requires Python >=3.5"
1: ! thus: matplotlib is forbidden
1: ! matplotlib (>=3.0,<4.0) is satisfied by matplotlib (^3.0)
1: ! which is caused by "test depends on matplotlib (^3.0)"
1: ! thus: version solving failed
1: Version solving took 0.247 seconds.
1: Tried 1 solutions.

[SolverProblemError]
The current supported Python versions are *
Because no versions of matplotlib match >3.0,<3.0.1 || >3.0.1,<4.0
and matplotlib (3.0.0) requires Python >=3.5, matplotlib is forbidden.
So, because matplotlib (3.0.1) requires Python >=3.5
and test depends on matplotlib (^3.0), version solving failed.

Exception trace:
/home/mbello/.poetry/lib/poetry/vendor/py3.6/cleo/application.py in run() at line 94
status_code = self.do_run(input
, output_)
/home/mbello/.poetry/lib/poetry/console/application.py in do_run() at line 88
return super(Application, self).do_run(i, o)
/home/mbello/.poetry/lib/poetry/vendor/py3.6/cleo/application.py in do_run() at line 197
status_code = command.run(input
, output_)
/home/mbello/.poetry/lib/poetry/console/commands/command.py in run() at line 77
return super(BaseCommand, self).run(i, o)
/home/mbello/.poetry/lib/poetry/vendor/py3.6/cleo/commands/base_command.py in run() at line 146
status_code = self.execute(input
, output_)
/home/mbello/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py in execute() at line 107
return self.handle()
/home/mbello/.poetry/lib/poetry/console/commands/add.py in handle() at line 139
status = installer.run()
/home/mbello/.poetry/lib/poetry/installation/installer.py in run() at line 76
self._do_install(local_repo)
/home/mbello/.poetry/lib/poetry/installation/installer.py in _do_install() at line 158
ops = solver.solve(use_latest=self._whitelist)
/home/mbello/.poetry/lib/poetry/puzzle/solver.py in solve() at line 37
packages, depths = self._solve(use_latest=use_latest)
/home/mbello/.poetry/lib/poetry/puzzle/solver.py in _solve() at line 154
raise SolverProblemError(e)

add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] ()...

$ poetry run pip install matplotlib
Collecting matplotlib
Using cached https://files.pythonhosted.org/packages/1e/f8/4aba1144dad8c67db060049d1a8bc740ad9fa35288d21b82bb85de69ff15/matplotlib-3.0.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting python-dateutil>=2.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/74/68/d87d9b36af36f44254a8d512cbfc48369103a3b9e474be9bdfe536abfc45/python_dateutil-2.7.5-py2.py3-none-any.whl
Collecting cycler>=0.10 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/2b/4a/f06b45ab9690d4c37641ec776f7ad691974f4cf6943a73267475b05cbfca/pyparsing-2.2.2-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/69/a7/88719d132b18300b4369fbffa741841cfd36d1e637e1990f27929945b538/kiwisolver-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.10.0 (from matplotlib)
Using cached https://files.pythonhosted.org/packages/16/21/2e88568c134cc3c8d22af290865e2abbd86efa58a1358ffcb19b6c74f9a3/numpy-1.15.3-cp36-cp36m-manylinux1_x86_64.whl
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./.venv/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib)
Installing collected packages: six, python-dateutil, cycler, pyparsing, kiwisolver, numpy, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.1 numpy-1.15.3 pyparsing-2.2.2 python-dateutil-2.7.5 six-1.11.0

@mbello
Copy link
Author

mbello commented Oct 30, 2018

Ok, I manually edited pyproject.toml and it now works.

Where I had:
[tool.poetry.dependencies]
python = "*"

Now I have:
[tool.poetry.dependencies]
python = "3.6"

Now I am not sure if I was supposed to hand edit that file, but I do not remember reading it in the docs. I have been using poetry for two months now and it was the first time I faced this difficulty.
If not a bug, definitely amn improvement.

@sdispater
Copy link
Member

This is the expected behavior and the error says it all: matplotlib (3.0.0) requires Python >=3.5 while your project was compatible with any Python version (python = "*") so matplotlib (3.0.0) could not be selected. And since there is no other matplotlib version that maches ^3.0, the dependencies could not be resolved.

@mbello
Copy link
Author

mbello commented Oct 31, 2018

Not so fast. The message does not explain the problem well, the message a user sees is:

"[SolverProblemError]
The current supported Python versions are *
Because no versions of matplotlib match >3.0,<3.0.1 || >3.0.1,<4.0
and matplotlib (3.0.0) requires Python >=3.5, matplotlib is forbidden.
So, because matplotlib (3.0.1) requires Python >=3.5
and test depends on matplotlib (^3.0), version solving failed."

If any version is supported and matplotlib requires a supported version why is this dependency not met?

Then I thought: well, if I am running python 3.6.6 and matplotlib requires >=3.5 why is poetry complaining and not just doing what I need it to do?

It was only when filling this bug report I was asked to show the contents of pyproject.toml and saw the relevant line.

If you designed the software in this way, so be it, but I would (A) improve the message and (B) improve the default setting.

(A)
Change:
"The current supported Python versions are * "
To something like:
"Based on your pyproject.toml file, this project must work with python versions: * (all python versions)"

(B)
Instead of python="*" by default, use python=">=3.5 if python version in use >=3.5"

@sdispater
Copy link
Member

If any version is supported and matplotlib requires a supported version why is this dependency not met?

This is the other way around. Poetry will always try to find a package version that is compatible with the all the versions supported by the project.

But I admit that the wording is not the clearest. I will see if I can improve it.

@sdispater sdispater added enhancement area/solver Related to the dependency resolver labels Nov 1, 2018
@mbello
Copy link
Author

mbello commented Nov 7, 2018

Ok, but keep in mind that today a simple sequence of commands like the one bellow will cause error and will lead new users to the conclusion that poetry is broken right from the start. I would change this default behavior and avoid having people leave before they even taste poetry!

mbello@mbello:/PycharmProjects$ poetry new myproject
Created package myproject in myproject
mbello@mbello:
/PycharmProjects$ cd myproject/
mbello@mbello:~/PycharmProjects/myproject$ poetry add pandas
Creating virtualenv myproject-py3.6 in /home/mbello/PycharmProjects/myproject/.venv
Using version ^0.23.4 for pandas

Updating dependencies
Resolving dependencies... (0.1s)

[SolverProblemError]
The current supported Python versions are *
Because no versions of pandas match >0.23.4,<0.24.0
and pandas (0.23.4) requires Python >=2.7,!=3.0.,!=3.1.,!=3.2.,!=3.3.,!=3.4.*, pandas is forbidden.
So, because myproject depends on pandas (^0.23.4), version solving failed.

add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] ()...

@sdispater
Copy link
Member

The default behavior will not change since I prefer people stumbling on the error when adding the package and make it clear for them what's going on than locking a version of a package that is not compatible with the Python versions supported by the project and lead to the confusion of not understanding why the package does not appear in non-supported Python versions.

@sdispater
Copy link
Member

The error message has been improved in the latest 1.0.0 version.

Copy link

github-actions bot commented Mar 3, 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 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/solver Related to the dependency resolver kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

3 participants