jupyterlab_code_formatter: Error writing grammar tables

I get an error upon launching Jupyter Lab with this extension enabled:

[I 10:37:25.686 LabApp] Node v10.8.0

[I 10:37:26.075 LabApp] Build is up to date
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\Grammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\Grammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\Grammar3.7.1.final.0.pickle'
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\PatternGrammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\PatternGrammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\PatternGrammar3.7.1.final.0.pickle'

After manually creating the folder C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0 and relaunching Jupyter lab the error disappears (even though the folder seems to stay empty).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Same here with MacOS BigSur

Same issue here as @andreamoro with new Mac OS X Catalina.

Hey! This seems to be Python in Windows shenanigans, this is something that this package will not aim to fix/workaround, thanks for the heads up though 👍 , shall put it in the readme

No error after I created the directory /home/roach/.cache/black/19.3b0.

[I 19:56:30.440 LabApp] Build is up to date
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/Grammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/Grammar3.7.3.final.0.pickle
Generating grammar tables from /home/roach/.virtualenvs/nn/lib/python3.7/site-packages/blib2to3/PatternGrammar.txt
Writing grammar tables to /home/roach/.cache/black/19.3b0/PatternGrammar3.7.3.final.0.pickle

And then if I reboot jupyterlab it will not show infos about black.

Can’t reproduce the error myself unfortunately… Could you try manually creating the /home/roach/.cache/black/19.3b0 dir and see what happens?

I understand this is a bit shitty but I can’t think of why it would not write the pickle in the cache 🤔

@ryantam626 I seem to experience the same issue on Ubuntu 16.04, so it appears to be OS independent.