Error writing grammar tables
EWouters opened this issue ยท 19 comments
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).
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
@ryantam626 I seem to experience the same issue on Ubuntu 16.04, so it appears to be OS independent.
Did you use your system's python to install jupyterlab or virtualenv/conda?
I actually use pyenv. Could that have something to do with the issue?
Hmm not that familiar with pyenv, but possibly. I think this is because the jupyterlab server is spawned with user that doesn't have privilege to create the cache needed for black. Did it work for you in the end? You could try creating the cache dir youself and chown to you user if not ๐ค
Same issue on Manjaro, using virtualenv.
[I 07:45:47.225 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
Writing failed: [Errno 2] No such file or directory: '/home/roach/.cache/black/19.3b0/tmpuxr828wb'
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
Writing failed: [Errno 2] No such file or directory: '/home/roach/.cache/black/19.3b0/tmpc5xlgf9q'
And, there is no black
directory under .cache
.
Interesting.. What does the directory ownership look like for /home/roach/.cache
? And what user did you start jupyterlab with?
hmank ~ ยป whoami
roach
hmank ~ ยป la | grep .cache
drwxr-xr-x 53 roach roach 4.0K 7ๆ 30 17:41 .cache
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 ๐ค
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
.
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
.
Ah good. I assume it's working as expected now?
Yes, except have to mkdir by myself.
Had the same issue, manually created .cache/black/19.10b0
. The error disappeared but code formatting still wouldn't work with black
. I had to move to autopep8
instead.
I can confirm, that this bug is present for Linux, too ( #82 ).
As we use JupyterLab in a multi-user environment with >300 user, it would be an somehow ugly workaround to mkdir ~/.cache/black/19.10b/ in everyones $HOME.
Linking root cause: psf/black#1223
Same here on a Mac OSX with a clean environment and brand new installation of the code formatter.
The directory was not created.
Same issue here as @andreamoro with new Mac OS X Catalina.
Same here with MacOS BigSur