15

When installing with pip, pip install sqlalchemy all is ok.

When installing with poetry I am getting the error

➜  backend poetry add sqlalchemy
Using version ^1.4.23 for SQLAlchemy

Updating dependencies
Resolving dependencies... (0.1s)

  AttributeError

  'EmptyConstraint' object has no attribute 'allows'

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/version/markers.py:291 in validate
      287│
      288│         if self._name not in environment:
      289│             return True
      290│
    → 291│         return self._constraint.allows(self._parser(environment[self._name]))
      292│
      293│     def without_extras(self):  # type: () -> MarkerTypes
      294│         return self.exclude("extra")
      295│
➜  backend
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Maksych
  • 153
  • 1
  • 4

6 Answers6

12

Try poetry self update, then poetry update.

fl_
  • 152
  • 6
2

If you use

poetry add sqlalchemy=1.4.22

This will solve your problem

Ntjs95
  • 128
  • 1
  • 8
1

Try upgrading poetry itself: pip install -U poetry. Worked for me to resolve SQLAlchemy issue.

Evgeny
  • 4,173
  • 2
  • 19
  • 39
0

I tried fl_'s answer but poetry self update itself failed for me with an error saying:

ModuleNotFoundError: No module named 'poetry.console'

From a stackoverflow answer to a different question I learned that I had poetry installed using the older, now deprecated, get-poetry.py.

So I uninstalled poetry like so:

curl https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry

python get-poetry --uninstall

Then reinstalled it with the newer install-poetry.py as per official installation instructions.

This finally made the original AttributeError go away.

urig
  • 16,016
  • 26
  • 115
  • 184
0

Same here, it seems to be a very recent problem. The good news is that "poetry self update" fixes the issue

ak-empiak
  • 41
  • 1
0

Upgrading poetry to 1.1.8 may solve the issue.

e.g. use poetry self update (related docs)

Check related poetry issue too:

https://github.com/python-poetry/poetry/issues/4410#issuecomment-902144234

zerocewl
  • 11,401
  • 6
  • 27
  • 53