psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.56k stars 2.43k forks source link

black module doesnt work on python 3.7 (Windows) #1167

Closed maki-markie closed 4 years ago

maki-markie commented 4 years ago

Hi There, Since I updated to python 3.7+ the black code formating module doesnt work anymore. Is there any news about this or any patch? Thanks in advance! Maki

zsol commented 4 years ago

It should, we're running it in CI. What's the error message?

maki-markie commented 4 years ago

It doesnt have any. Im working in VSCODE and set the formating to black. It was fine with 3.6 but since i updated to 3.7 it just stopped working to format the codes.

maki-markie commented 4 years ago

It should, we're running it in CI. What's the error message? i have the latest black version: black 19.10b0

$ black signal_data.py
Traceback (most recent call last):
  File "AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "venv\Scripts\black.exe\__main__.py", line 4, in <module>
  File "venv\lib\site-packages\black.py", line 2, in <module>
    import asyncio
  File "AppData\Local\Programs\Python\Python37\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 39, in <module>
    from . import events
  File "AppData\Local\Programs\Python\Python37\lib\asyncio\events.py", line 14, in <module>
    import contextvars
  File "AppData\Local\Programs\Python\Python37\lib\contextvars.py", line 1, in <module>
    from _contextvars import Context, ContextVar, Token, copy_context
ModuleNotFoundError: No module named '_contextvars'
JelleZijlstra commented 4 years ago

This seems like a problem with your installation. _contextvars is part of the standard library.

maki-markie commented 4 years ago

i have the latest black version: black 19.10b0 reinstalled. Even tho i can see the module when i pip list in my venv, this gives me this error message.

asottile commented 4 years ago

This particular error happens when upgrading the system version of python and having an old virtualenv -- try recreating your virtualenv (the python standard library does not have stable exports between patch versions which frequently breaks previously created virtualenvs)