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

Python 3.11 ModuleNotFoundError: No module named 'tomllib' #2983

Closed
PerchunPak opened this issue Mar 31, 2022 · 5 comments
Closed

Python 3.11 ModuleNotFoundError: No module named 'tomllib' #2983

PerchunPak opened this issue Mar 31, 2022 · 5 comments
Labels
C: dependencies C: packaging Installation and packaging of Black T: bug Something isn't working

Comments

@PerchunPak
Copy link

Describe the bug

In Python 3.11 it is raising exception with ModuleNotFoundError.

To Reproduce

Install Python 3.11

$ black .

The resulting error is:

Traceback (most recent call last):
  File "/home/runner/work/autodonate/autodonate/.venv/bin/black", line 5, in <module>
    from black import patched_main
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/autodonate/autodonate/.venv/lib/python3.11/site-packages/black/__init__.py", line 52, in <module>
    from black.files import (
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/autodonate/autodonate/.venv/lib/python3.11/site-packages/black/files.py", line 25, in <module>
    import tomllib
    ^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tomllib'

Environment

  • Black's version: 22.3.0
  • OS and Python version: Github Actions Ubuntu, Python 3.11

Additional context

Logs from my CI.
Also, why you haven't did any CI on 3.11?

@PerchunPak PerchunPak added the T: bug Something isn't working label Mar 31, 2022
@JelleZijlstra
Copy link
Collaborator

Python 3.11 is still in alpha. The released version will have tomllib available, but whatever alpha version you're running might not have it yet. We'll run 3.11 in CI once we're closer to the release date for 3.11.

@ichard26
Copy link
Collaborator

I will also note that I have tried testing 3.11-dev in GHA CI, but last time I tried our dependencies weren't 3.11 ready: 0505c8f and https://github.com/psf/black/runs/5504048923?check_suite_focus=true

I did actually schedule a reminder to try again when the first beta comes out, but I'd be open to trying again soon.

@ichard26 ichard26 added the C: packaging Installation and packaging of Black label Mar 31, 2022
@SamuelMarks
Copy link

Also this did work on 3.11.0-alpha.5 with black-22.1.0-py3-none-any.whl just not 3.11.0-alpha.6 with black-22.3.0-py3-none-any.whl.

@pawamoy
Copy link

pawamoy commented Apr 1, 2022

Would it be possible to change to a try/except (and put back tomli as dep without marker) instead of a condition on the Python version, at least until tomllib is available in Python 3.11 (alpha or not)? I understand 3.11 is still alpha, but I believe many users want to test their code and run their CI tools (i.e. Black) on Python 3.11. Of course I can pin Black to <22.3 for Python 3.11 only (with markers), but that's a bit cumbersome to do in every project 😕

@JelleZijlstra
Copy link
Collaborator

@pawamoy that's fair, opened #2987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: dependencies C: packaging Installation and packaging of Black T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants