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

AttributeError on running "poetry install" #2372

Open
3 tasks done
pavdmyt opened this issue May 2, 2020 · 8 comments
Open
3 tasks done

AttributeError on running "poetry install" #2372

pavdmyt opened this issue May 2, 2020 · 8 comments
Labels
area/error-handling Bad error messages/insufficient error handling kind/enhancement Not a bug or feature, but improves usability or performance

Comments

@pavdmyt
Copy link

pavdmyt commented May 2, 2020

  • 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: macOS Mojave, version 10.14.6
  • Poetry version: 1.0.5

Issue

Having a pyproject.toml with the following tool.poetry.dependencies section:

[tool.poetry.dependencies]
python = "~2.7, >=3.4, <3.8"

Running poetry install results in AttributeError:

$ poetry install -vvv

[AttributeError]
EmptyConstraint instance has no attribute 'min'

Traceback (most recent call last):
  File "/Users/me/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/me/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/me/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/Users/me/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/Users/me/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/Users/me/.poetry/lib/poetry/console/config/application_config.py", line 86, in set_env
    poetry = command.poetry
  File "/Users/me/.poetry/lib/poetry/console/commands/command.py", line 10, in poetry
    return self.application.poetry
  File "/Users/me/.poetry/lib/poetry/console/application.py", line 49, in poetry
    self._poetry = Factory().create_poetry(Path.cwd())
  File "/Users/me/.poetry/lib/poetry/factory.py", line 90, in create_poetry
    package.python_versions = constraint
  File "/Users/me/.poetry/lib/poetry/packages/project_package.py", line 45, in python_versions
    create_nested_marker('python_version', self._python_constraint)
  File "/Users/me/.poetry/lib/poetry/packages/utils/utils.py", line 214, in create_nested_marker
    if constraint.min is not None:

However, poetry check returns no errors:

$ poetry check
All set!

So, I'm making a conclusion that python = "~2.7, >=3.4, <3.8" is a valid version constraint.

@pavdmyt pavdmyt added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 2, 2020
@abn
Copy link
Member

abn commented May 2, 2020

@pavdmyt I beielve the constraint you are looking for is ^2.7 || >=3.4 <3.8.

@abn abn added area/error-handling Bad error messages/insufficient error handling kind/enhancement Not a bug or feature, but improves usability or performance and removed kind/bug Something isn't working as expected labels May 2, 2020
@pavdmyt
Copy link
Author

pavdmyt commented May 4, 2020

@abn Thanks! I didn't find OR operator in docs.

My point is more about that in described case the AttributeError: EmptyConstraint instance has no attribute 'min' is not really helpful and poetry check accepts obviously invalid requirement: python = "~2.7, >=3.4, <3.8", without failure.

@andreoliwa
Copy link

I'm having the same error on Poetry 1.0.9.

The package I'm trying (AuHau/toggl-cli) has:

python_requires = >=3.6.0, <3.9.0

This is my debug info, and a gist below with pyproject.toml and the full error log.

Poetry
Version: 1.0.9
Python:  3.8.3

Virtualenv
Python:         3.8.3
Implementation: CPython
Path:           /Users/wagneraugusto/Library/Caches/pypoetry/virtualenvs/toggl-cli-bug-t9z0mPRw-py3.8
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/wagneraugusto/.pyenv/versions/3.8.3

Poetry [AttributeError] 'EmptyConstraint' object has no attribute 'min'

(Note: yesterday I didn't see this open issue, so I left the same comment on #534, which I believe is a closed duplicated issue)

@nikmolnar
Copy link
Contributor

I'm experiencing this error in Poetry 1.1.5 when python ^2.7 and pytest are both listed. Here is a minimal example:

[tool.poetry]
name = "poetry-bug"
version = "0.1.0"
description = ""
authors = ["Me"]

[tool.poetry.dependencies]
python = "^2.7"

[tool.poetry.dev-dependencies]
pytest = "*"

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

Running poetry lock will result in the aforementioned EmptyConstraint error. Changing the Python version to ^3.6 or removing the pytest dev dependency will work correctly.

@pawamoy
Copy link

pawamoy commented Apr 1, 2021

Experiencing the same thing with python = "^3.6".

@ghost
Copy link

ghost commented Apr 2, 2021

👍 Also encountering this issue today w/ Python 3.8.

UPDATE: pytest-randomly caused the issue. This comment here helped fix the problem. I downgraded pytest-randomly to 3.5.0. #3862 (comment)

@jedie
Copy link

jedie commented Apr 5, 2021

I ran into this bug, too. And yes, it's caused by pytest-randomly

Work-a-round: pytest-randomly = "!=3.6.0"

But i think poetry should raise a better error messages than this:

grafik

Think we should get the package name that caused the error, isn't it?

VaultVulp added a commit to great-glow/cookiecutter-python-template that referenced this issue Apr 8, 2021
* Bump apprise action
* Switch to s4cmd
* Lock pytest-randomly (python-poetry/poetry#2372)
* Mitigate changes to GITHUB_TOKEN
@mforbes
Copy link

mforbes commented May 7, 2021

This is probably a documentation issue. According to the docs:

Multiple version requirements can also be separated with a comma, e.g. >= 1.2, < 1.5.

This should probably explicitly state that a comma in this corresponds to logical and, and an example with logical or || should be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/error-handling Bad error messages/insufficient error handling kind/enhancement Not a bug or feature, but improves usability or performance
Projects
None yet
Development

No branches or pull requests

8 participants