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

No module named 'dataclasses' in Python 3.6.9 #1645

Closed
l0b0 opened this issue Aug 28, 2020 · 6 comments · Fixed by #2511
Closed

No module named 'dataclasses' in Python 3.6.9 #1645

l0b0 opened this issue Aug 28, 2020 · 6 comments · Fixed by #2511

Comments

@l0b0
Copy link

l0b0 commented Aug 28, 2020

Python 3.6 doesn't have dataclasses, so the following fails:

Traceback (most recent call last):
  File "…/.venv/bin/black", line 7, in <module>
    from black import patched_main
  File "…/.venv/lib/python3.6/site-packages/black/__init__.py", line 49, in <module>
    from dataclasses import dataclass, field, replace
@ichard26
Copy link
Collaborator

Not sure how that could happen as the requirement of dataclasses is listed in setup.py... 😕

black/setup.py

Lines 70 to 80 in 2b75f88

install_requires=[
"click>=7.1.2",
"appdirs",
"toml>=0.10.1",
"typed-ast>=1.4.0",
"regex>=2020.1.8",
"pathspec>=0.6, <1",
"dataclasses>=0.6; python_version < '3.7'",
"typing_extensions>=3.7.4",
"mypy_extensions>=0.4.3",
],

@l0b0
Copy link
Author

l0b0 commented Aug 28, 2020

I tried changing pyproject.toml from black = {version = "^19.10b0", allow-prereleases = true} to black = {version = "*", allow-prereleases = true}. This results in an upgrade to 20.8b1 (poetry update prints "Updating black (19.10b0 -> 20.8b1)") and an entry in poetry.lock for the "dataclasses" package:

[[package]]
category = "main"
description = "A backport of the dataclasses module for Python 3.6"
marker = "python_version < \"3.7\""
name = "dataclasses"
optional = false
python-versions = ">=3.6, <3.7"
version = "0.7"

[package.source]
reference = "package proxy"
type = "legacy"
url = "http://…/root/pypi/+simple"

But for whatever reason it looks like it's not being installed - poetry update doesn't print anything about the "dataclasses" package, and the Virtualenv doesn't have it:

$ find .venv -name '*dataclasses*'
.venv/lib/python3.6/site-packages/isort/_future/__pycache__/_dataclasses.cpython-36.pyc
.venv/lib/python3.6/site-packages/isort/_future/_dataclasses.py
.venv/lib/python3.6/site-packages/astroid/brain/__pycache__/brain_dataclasses.cpython-36.pyc
.venv/lib/python3.6/site-packages/astroid/brain/brain_dataclasses.py
.venv/lib/python3.6/site-packages/mypy/plugins/dataclasses.py
.venv/lib/python3.6/site-packages/mypy/plugins/dataclasses.cpython-36m-x86_64-linux-gnu.so
.venv/lib/python3.6/site-packages/mypy/plugins/__pycache__/dataclasses.cpython-36.pyc
.venv/lib/python3.6/site-packages/mypy/typeshed/stdlib/3.7/dataclasses.pyi
.venv/lib/python3.6/site-packages/mypy/typeshed/third_party/3/dataclasses.pyi

Running poetry install afterwards doesn't make any difference.

@JelleZijlstra
Copy link
Collaborator

Yes, looks like a Poetry issue.

@Cheukting
Copy link

I did not use Poetry but came across the same issue. It's tox on a Travis build.

@Cheukting
Copy link

I think this maybe the issue: pypa/pip#8686

@erdnaxeli
Copy link

I think this maybe the issue: pypa/pip#8686

I am not sure this is it, this issue is about using extra != a. Here the check is about the python version.

I use pipenv and I can reproduce the bug.

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

Successfully merging a pull request may close this issue.

5 participants