prusnak / suez

Tool for pretty printing and optimizing Lightning Network channels.
GNU General Public License v3.0
78 stars 20 forks source link

ModuleNotFoundError: No module named 'dataclasses' #12

Closed sipsorcery closed 3 years ago

sipsorcery commented 3 years ago

$ uname -a Linux btcaz 5.4.0-1046 #48~18.04.1-Ubuntu SMP Tue Apr 13 19:41:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic

$ python3 --version Python 3.6.9

$ poetry --version Poetry version 1.1.6

$ git log commit 1894ea0bfffa87b142501557c2f82def2028a4b5 (HEAD -> master, origin/master, origin/HEAD)

$ poetry run ./suez

Traceback (most recent call last):
  File "./suez", line 2, in <module>
    from suez import suez
  File "/home/azureuser/src/suez/suez.py", line 5, in <module>
    from rich.console import Console
  File "/home/azureuser/.cache/pypoetry/virtualenvs/suez-qnYOxQkH-py3.6/lib/python3.6/site-packages/rich/console.py", line 9, in <module>
    from dataclasses import dataclass, field
ModuleNotFoundError: No module named 'dataclasses'
prusnak commented 3 years ago

This looks like an issue with your setup, rather than issue with suez.

Did you run poetry install ?

sipsorcery commented 3 years ago

Did you run poetry install ?

Yes I installed poetry, as per the docs, and then ran poetry install .

sipsorcery commented 3 years ago

I fixed it by making these changes to pyproject.toml. I don't really know what I'm doing with Python configs though so not sure if it's the correct way or not.

[tool.poetry.dependencies]
python = ">=3.6.2,<4.0"
rich = "^10.2.2"
click = "^8.0.1"
dataclasses = {version = "^0.7", python = "~3.6.1"}
prusnak commented 3 years ago

Added in 300dfee4c240f99d34bc1f846c0b84cf708e7468

Can you please confirm the commit works for you?

sipsorcery commented 3 years ago

Added in 300dfee

Can you please confirm the commit works for you?

No it doesn't.

The python = ">=3.6.2,<4.0" line is what fixes it. The dataclasses line turns out not to be necessary, at least for me.

prusnak commented 3 years ago

python = "^3.6" is equivalent to python = ">=3.6.0,<4.0" python = "~3.6" is equivalent to python = ">=3.6.0,<3.7.0"

It seems there is something weird with your setup, but since you were able to fix it, I am closing this issue. Thanks for the report.

sipsorcery commented 3 years ago

python = "^3.6" is equivalent to python = ">=3.6.0,<4.0" python = "~3.6" is equivalent to python = ">=3.6.0,<3.7.0"

Beats me, I just did what poetry recommended, see below. I doubt it's my environment as the behaviour is identical on two separate machines. At least it's documented here now in case anyone else has the same issue.

$ poetry update

Updating dependencies
Resolving dependencies... (0.0s)

  SolverProblemError

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

  Because no versions of black match >21.5b2,<21.6b0 || >21.6b0,<22.0
   and black (21.5b2) requires Python >=3.6.2, black is forbidden.
  So, because black (21.6b0) requires Python >=3.6.2
   and suez depends on black (^21.5b2), 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

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

    For black, a possible solution would be to set the `python` property to ">=3.6.2,<4.0"
    For black, a possible solution would be to set the `python` property to ">=3.6.2,<4.0"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers
prusnak commented 3 years ago

Makes sense, the error above is completely new and unrelated to dataclasses.

It is related to black and I fixed that in d078dee0fb2e2eed5e6944b5676e4a40d7e1b0ad

Thanks!