Open BobCu opened 3 years ago
Could you run jupyter server extension enable --py jupyterlab_code_formatter
and retry?
I think this line was removed from the README by mistake.
Okay removing it from the README was not a mistake, I just didn't publish the package which I have now. If you upgrade to 1.4.2, it should automatically do this and work.
I too have been trying to get this setup on a JupyterHub/JupyterLab 3.0.5 setup on Ubuntu 18.04. Just tried the 1.4.2 release and still see the unknown version dialog message after restarting JupyterLab.
Doing jupyter server extension enable --py jupyterlab_code_formatter should work
I did try that based on the comment above, and it seems like things are installed correctly:
jupyter@jupyterhub:~$ jupyter server extension list
Config dir: /opt/tljh/user/etc/jupyter
jupyter_lsp enabled
- Validating jupyter_lsp...
jupyter_lsp 1.0.0 OK
jupyterlab enabled
- Validating jupyterlab...
jupyterlab 3.0.5 OK
jupyterlab_code_formatter enabled
- Validating jupyterlab_code_formatter...
jupyterlab_code_formatter 1.4.2 OK
jupytext enabled
- Validating jupytext...
jupytext 1.9.1 OK
nbclassic enabled
- Validating nbclassic...
nbclassic OK
Config dir: /usr/local/etc/jupyter
And yet the dialog still pops up with the message:
Unable to find server plugin version, this should be impossible,open a GitHub issue if you cannot figure this issue out yourself.
JupyterHub starts the underlying server differently to how JupyterLab is now started under the hood (I think only since JL 3) . I just spent a whole day diving into this difference and found no easy fix. Anyone using the JupyterHub would need to wait for JupyterHub/JupyterLab people to update their code unfortunately.
For context here is what I found (which is entirely possible to be wrong since I don't have intimate knowledge of JupyterHub/JupyterLab internals):
notebook.notebookapp.NotebookApp
classJUPYTERHUB_SINGLEUSER_APP
env var, as the interface just seems to be different and will blow up when trying to apply the mixins.I think the question now is what to pass into JUPYTERHUB_SINGLEUSER_APP
env var and also what changes has to be done on JupyterHub/JupyterLab itself to support this..
The solution for me is here: https://github.com/jupyterhub/jupyterhub/pull/3329/files Just add the env var to your dockerfile
@s-rog Any idea where the best place to do that if I've installed JupyterHub on a VM, where each user logs into their own account?
I'm not sure as I'm running jupyterhub on k8s where each lab instance is spawned from a docker image
@sheinb perhaps this is helpful? https://github.com/krassowski/jupyterlab-lsp/issues/375#issuecomment-761078622
Thanks for the link. I tried this addition but it prevented my kernels from starting after restarting my TLJH hub. I do have LSP installed, but it seems to work properly (although I'm missing file path completion :-()
Could you run
jupyter server extension enable --py jupyterlab_code_formatter
and retry?
The above line seems to have resolved the popup warning. Still testing.
The command works fine and the server extension list
also indicates it’s installed:
(base) root@jupyterhub:~# jupyter server extension enable --py jupyterlab_code_formatter
Enabling: jupyterlab_code_formatter
- Writing config: /opt/tljh/user/etc/jupyter
- Validating jupyterlab_code_formatter...
jupyterlab_code_formatter 1.4.2 OK
- Extension successfully enabled.
…but the dialog still shows up. You can see from above that this is on a TLJH deployment.
On Jan 19, 2021, at 1:06 PM, BobCu notifications@github.com wrote:
Could you run jupyter server extension enable --py jupyterlab_code_formatter and retry?
The above line seems to have resolved the popup warning. Still testing.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ryantam626/jupyterlab_code_formatter/issues/193#issuecomment-763021654, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSZXGDTIVLQHM7DE2BH4PDS2XC2FANCNFSM4WBB6C3Q.
One oddity: The initial run failed due to /usr/etc
not existing on my system, which I created globally writable. After successful installation, the file /usr/etc/jupyter/jupyter_server_config.d/jupyterlab_code_formatter.json
had been created.
Shouldn't that file have been created in my user-local Jupyter config area, ~/.jupyter
?
One oddity: The initial run failed due to
/usr/etc
not existing on my system, which I created globally writable. After successful installation, the file/usr/etc/jupyter/jupyter_server_config.d/jupyterlab_code_formatter.json
had been created.Shouldn't that file have been created in my user-local Jupyter config area,
~/.jupyter
?
I am not really sure.
I have tested with this and it seems to work, I was literally one step away when I tested this last week :facepalm:
# get a shell with jupyter hub
docker run -p 8000:8000 -it --name jupyterhub jupyterhub/jupyterhub bash
# install stuff
pip install jupyterlab black isort jupyterlab_code_formatter
# add user
useradd -m ryan
# generate config
jupyterhub --generate-config
# simple auth for testing
echo "c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator'" >> jupyterhub_config.py
echo "c.DummyAuthenticator.password = 'abc'" >> jupyterhub_config.py
# spin jupyter hub up
JUPYTERHUB_SINGLEUSER_APP='jupyter_server.serverapp.ServerApp' jupyterhub -f jupyterhub_config.py
# go to localhost:8000 on your host
# login with whatever user you created (`ryan`) in my case, password is `abc`
# http://localhost:8000/user/ryan/ should just say `A Jupyter Server is running.` which is where i got confused last week (replace name of user if needed)
# http://localhost:8000/user/ryan/lab should have a usable lab instance now (replace name of user if needed)
I am having this issue using 1.3.8 version of plugin&extension. (1.3.6 also tried)
pip install jupyterlab_code_formatter==1.3.6 && \
jupyter serverextension enable --py jupyterlab_code_formatter && \
jupyter server extension enable jupyterlab_code_formatter --user && \ # tried this too
jupyter labextension install @ryantam626/jupyterlab_code_formatter@v1.3.6 && \
My jupyterlab version is 2.2.9. I am not using 1.4 version of jupyterlab_code_formatter because it update my jupterlab to 3, which is something I don't want yet.
At first start, (after showing issue error) jupyter serverextension list does not show formatter as enabled. After a jupyter serverextension enable --py jupyterlab_code_formatter
in terminal, it mark it as enabled, but nothing changes. Error still pop up, ant obviously the tool is not available.
I also tried 1.3.2 same behaviour without pop up.
No jupyterhub involved, just jupyterlab
Updated our TLJupyterHub+JupyterLab to 3.0.7 and reinstalled the extension, and no more "unknown version" dialog message and the format cell appears as expected in the drop down!
A couple of cases that produce this error:
"jupyterlab_code_formatter": true
in ServerApp.jpserver_extensions
languageserver
installed correctly (double check env vars like $R_HOME
and $R_LIBS_SITE
and be sure rpy2
is using the same R environment)Just sharing my experience in case it might help others: No matter what I did, I kept getting the pop up error: Unable to find server plugin version, this should be impossible,open a GitHub issue if you cannot figure this issue out yourself. I tried re-installing the plugin, updating my jupyterlab
to version 3+, manually enabling it via jupyter server extension enable --py jupyterlab_code_formatter
.
In the end, I delete the conda cache via conda clean --all --force-pkgs-dir
(the --force-pkgs-dir
was essential), and then reinstalled the plugin, and everything just worked.
Thanks all! I just updated my pip install --user
version of JupyterLab and had to set this in ~/.jupyter/jupyter_server_config.py
:
c.ServerApp.jpserver_extensions = {
"jupyterlab": True,
"jupyterlab_code_formatter": True,
}
The ~/.jupyter/jupyter_server_config.py
is necessary (and was not shown in the commented-out default value), because otherwise jupyter lab
will not run at all.
The solution for me is here: https://github.com/jupyterhub/jupyterhub/pull/3329/files Just add the env var to your dockerfile
I found that is used for Linux '-' do you know how to solve in window
jupyter server extension enable --py jupyterlab_code_formatter --user
Works for me.
Could you run
jupyter server extension enable --py jupyterlab_code_formatter
and retry?I think this line was removed from the README by mistake.
I have the same error as OP. Running your commands gives an error - https://i.imgur.com/UUEo236.png
Had a similar issue when following the documentation together with a Jupyter Lab 3.2.2 install on a macbook M1, jupyter server extension enable --py jupyterlab_code_formatter
fixed it. The plugin works fine now.
A couple of cases that produce this error:
- not having
"jupyterlab_code_formatter": true
inServerApp.jpserver_extensions
- if you're formatting R code, not having R and the R package
languageserver
installed correctly (double check env vars like$R_HOME
and$R_LIBS_SITE
and be surerpy2
is using the same R environment)
Maybe it is caused by R, because just after the installation of R in conda environment it occurs.
Similar problem, annoying.
My problem was the new config UI. Opening in JSON editing mode and removing/fixing default_formatter
key fixed my issue.
One of the ways to troubleshoot is to run 'jupyter serverextension list'. If it prints error message "Error loading server extension jupyterlab_code_formatter" then perform 'import jupyterlab_code_formatter' and investigate stack trace.
For me the culprit was that jupyter-nbclassic
replaced jupyter-notebook
on an Arch/Manjaro system. Re-replacing it by installing jupyter-notebook
again fixed it.
Also, removing user-lab files (e.g. .local/share/jupyter/labextensions
) was also necessary.
After using @ekungurov's suggestion, I found that python -c "import jupyterlab_code_formatter"
failed with ImportError: cannot import name 'cache' from 'functools'
. That package is only available in Python 3.9+ and I was on 3.8, so downgrading jupyterlab-code-formatter to 1.5.3 fixed the issue for me.
pip install jupyterlab-code-formatter==1.5.3
In my case, I'm using python 3.7 and python -c "import jupyterlab_code_formatter"
raises the error message ModuleNotFoundError: No module named 'importlib.metadata'
.
This is weird cause importlib.metadata
is installed on 4.11.4 version.
Anyway, comment by @glinka works on python 3.7 as well! Thank you!
I will try to improve the docs so the procedure to debug is more clear..
Checklist prior to opening an issue
Describe the bug After JupyterLab server start, opening a client yields the following popup:
Diagnostic commands Please attach the output of the following commands (please format them properly)
pip freeze
jupyter labextension list
jupyter serverextension list
Screenshots
Additional context
Running Python 3.8.5 under Ubuntu 20.04 under WSL2 under Windows 10. The rest is turtles all the way down.