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

ModuleNotFoundError: No module named 'dataclasses' #12

Closed
sipsorcery opened this issue Jun 13, 2021 · 8 comments
Closed

ModuleNotFoundError: No module named 'dataclasses' #12

sipsorcery opened this issue Jun 13, 2021 · 8 comments

Comments

@sipsorcery
Copy link

sipsorcery commented Jun 13, 2021

$ 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 1894ea0 (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
Copy link
Owner

prusnak commented Jun 13, 2021

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

Did you run poetry install ?

@sipsorcery
Copy link
Author

Did you run poetry install ?

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

@sipsorcery
Copy link
Author

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
Copy link
Owner

prusnak commented Jun 13, 2021

Added in 300dfee

Can you please confirm the commit works for you?

@sipsorcery
Copy link
Author

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
Copy link
Owner

prusnak commented Jun 13, 2021

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.

@prusnak prusnak closed this as completed Jun 13, 2021
@sipsorcery
Copy link
Author

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
Copy link
Owner

prusnak commented Jun 13, 2021

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

It is related to black and I fixed that in d078dee

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants