jupyterlab_code_formatter icon indicating copy to clipboard operation
jupyterlab_code_formatter copied to clipboard

Jupyterlab Code Formatter Error Unable to find server plugin version

Open BobCu opened this issue 4 years ago • 32 comments

Checklist prior to opening an issue

  • [X] I have followed fully the installation steps laid out in the documentation site.
  • [X] I have restarted jupyterlab.
  • [X] I have read the FAQ section in the documentation site.

Describe the bug After JupyterLab server start, opening a client yields the following popup:

Jupyterlab Code Formatter Error
Unable to find server plugin version, this should be impossible, open a GitHub issue if you cannot figure this issue out yourself.

Diagnostic commands Please attach the output of the following commands (please format them properly)

  • pip freeze
anyio==2.0.2
appdirs==1.4.4
argon2-cffi==20.1.0
arviz==0.10.0
astroid==2.4.2
async-generator==1.10
atomicwrites==1.1.5
attrs==20.3.0
Automat==20.2.0
autopep8==1.5.4
Babel==2.9.0
backcall==0.2.0
beautifulsoup4==4.9.3
black==20.8b1
bleach==3.2.1
blinker==1.4
boto==2.49.0
certifi==2020.12.5
cffi==1.14.4
cftime==1.3.0
chardet==4.0.0
click==7.1.2
cloud-init==20.4
colorama==0.4.4
command-not-found==0.3
configobj==5.0.6
constantly==15.1.0
cryptography==3.3.1
cssselect==1.1.0
cupshelpers==1.0
cvxopt==1.2.3
cycler==0.10.0
dbus-python==1.2.16
decorator==4.4.2
defer==1.0.6
defusedxml==0.6.0
dill==0.3.3
distro==1.5.0
distro-info===0.23ubuntu1
entrypoints==0.3
et-xmlfile==1.0.1
fastprogress==1.0.0
filelock==3.0.12
flake8==3.8.4
h5py==3.1.0
html5lib==1.1
httplib2==0.18.1
hyperlink==21.0.0
idna==2.10
importlib-metadata==3.4.0
incremental==17.5.0
ipykernel==5.4.3
ipympl==0.6.2
ipython==7.19.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
isort==5.7.0
itemadapter==0.2.0
itemloaders==1.0.4
jdcal==1.0
jedi==0.17.2
jeepney==0.6.0
Jinja2==2.11.2
jmespath==0.10.0
joblib==0.14.0
json5==0.9.5
jsonpatch==1.28
jsonpointer==2.0
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.11
jupyter-console==6.2.0
jupyter-core==4.7.0
jupyter-resource-usage==0.5.1
jupyter-server==1.2.1
jupyterlab==3.0.4
jupyterlab-code-formatter==1.4.1
jupyterlab-pygments==0.1.2
jupyterlab-server==2.1.2
jupyterlab-widgets==1.0.0
keyring==21.8.0
kiwisolver==1.3.1
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.3
lazr.uri==1.0.5
lazy-object-proxy==1.4.3
llvmlite==0.31.0
lxml==4.6.2
macaroonbakery==1.3.1
MarkupSafe==1.1.1
matplotlib==3.3.3
mccabe==0.6.1
mistune==0.8.4
modbus-cli==0.1.3
more-itertools==8.6.0
mypy-extensions==0.4.3
mysqlclient==1.4.4
nbclassic==0.2.6
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.0.8
nest-asyncio==1.4.3
netCDF4==1.5.5.1
netifaces==0.10.9
nose==1.3.7
notebook==6.1.6
numba==0.48.0
numexpr==2.7.1
numpy==1.19.4
oauthlib==3.1.0
olefile==0.46
openpyxl==3.0.3
packaging==20.8
pandas==1.2.0
pandocfilters==1.4.3
parsel==1.6.0
parso==0.7.1
pathspec==0.8.1
patsy==0.5.1
pbr==5.5.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.1.0
pip-tools==5.5.0
pluggy==0.13.1
prometheus-client==0.9.0
prompt-toolkit==3.0.10
Protego==0.1.16
protobuf==3.14.0
psutil==5.8.0
ptyprocess==0.7.0
py==1.8.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycairo==1.16.2
pycodestyle==2.6.0
pycparser==2.20
pycups==1.9.73
PyDispatcher==2.0.5
pydocstyle==5.1.1
pyflakes==2.2.0
pyftdi==0.52.9
Pygments==2.7.4
PyGObject==3.36.0
PyHamcrest==2.0.2
PyJWT==1.7.1
pylint==2.6.0
pymacaroons==0.13.0
pymc3==3.10.0
PyNaCl==1.4.0
pyOpenSSL==20.0.1
pyparsing==2.4.7
pyRFC3339==1.1
pyrsistent==0.17.3
pyserial==3.5
pytest==4.6.9
python-apt==2.0.0+ubuntu0.20.4.3
python-dateutil==2.8.1
python-debian==0.1.39
python-jsonrpc-server==0.4.0
python-language-server==0.36.2
pytz==2020.5
pyusb==1.1.0
PyYAML==5.3.1
pyzmq==20.0.0
qtconsole==5.0.1
QtPy==1.9.0
queuelib==1.5.0
regex==2020.11.13
requests==2.25.1
requests-unixsocket==0.2.0
rope==0.18.0
scikit-learn==0.22.2.post1
scipy==1.5.4
Scrapy==2.4.1
seaborn==0.11.1
SecretStorage==3.3.0
Send2Trash==1.5.0
service-identity==18.1.0
sidetable==0.8.0
simplejson==3.17.2
six==1.15.0
sklearn-pandas==1.8.0
sniffio==1.2.0
snowballstemmer==2.0.0
sos==4.0
soupsieve==2.1
ssh-import-id==5.11
statsmodels==0.11.1
systemd-python==234
tables==3.6.1
terminado==0.9.2
testpath==0.4.4
testresources==2.0.1
Theano==1.0.5
Theano-PyMC==1.1.0
toml==0.10.2
tornado==6.1
traitlets==5.0.5
Twisted==20.3.0
typed-ast==1.4.2
typing-extensions==3.7.4.3
ubuntu-advantage-tools==20.3
ufw==0.36
ujson==4.0.1
uModbus==1.0.4
unattended-upgrades==0.1
urllib3==1.26.2
w3lib==1.22.0
wadllib==1.3.4
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
wrapt==1.12.1
xarray==0.16.2
xlrd==1.1.0
xlwt==1.3.0
yapf==0.30.0
zipp==3.4.0
zope.interface==5.2.0
  • jupyter labextension list
JupyterLab v3.0.4
/home/bobc/.local/share/jupyter/labextensions
        jupyter-matplotlib v0.8.2 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
        @ryantam626/jupyterlab_code_formatter v1.4.1 enabled OK (python, jupyterlab-code-formatter)
        @jupyter-server/resource-usage v0.5.0 enabled OK (python, jupyter-resource-usage)

Other labextensions (built into JupyterLab)
   app dir: /home/bobc/.local/share/jupyter/lab
        @krassowski/jupyterlab-lsp v2.1.0 enabled OK

  • jupyter serverextension list
config dir: /home/bobc/.jupyter
    jupyterlab_code_formatter  enabled
    - Validating...
      X is jupyterlab_code_formatter importable?

Screenshots

JupyterLab_error

Additional context

Running Python 3.8.5 under Ubuntu 20.04 under WSL2 under Windows 10. The rest is turtles all the way down.

BobCu avatar Jan 13 '21 16:01 BobCu

Could you run jupyter server extension enable --py jupyterlab_code_formatter and retry?

I think this line was removed from the README by mistake.

ryantam626 avatar Jan 16 '21 12:01 ryantam626

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.

ryantam626 avatar Jan 16 '21 12:01 ryantam626

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.

sheinb avatar Jan 16 '21 16:01 sheinb

Doing jupyter server extension enable --py jupyterlab_code_formatter should work

alanzhong avatar Jan 16 '21 22:01 alanzhong

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.

sheinb avatar Jan 17 '21 01:01 sheinb

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):

  • JupyterHub spawn jupyter notebook server (which coincidentally supports lab somehow?) via https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/singleuser/app.py ,it modifies login and logout handler to provide JupyterHub's login/logout experience I blieve.
  • JupyterLab 3 now something from https://github.com/jupyter-server/jupyter_server or https://github.com/jupyterlab/jupyterlab_server which automatically loads the server extension for you, this behaviour is not replicated to the notebook.notebookapp.NotebookApp class
  • I am unable to pass JupyterLab 3's app classes into the JupyterHub singleuser script via JUPYTERHUB_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..

ryantam626 avatar Jan 18 '21 09:01 ryantam626

The solution for me is here: https://github.com/jupyterhub/jupyterhub/pull/3329/files Just add the env var to your dockerfile

s-rog avatar Jan 19 '21 02:01 s-rog

@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?

sheinb avatar Jan 19 '21 02:01 sheinb

I'm not sure as I'm running jupyterhub on k8s where each lab instance is spawned from a docker image

s-rog avatar Jan 19 '21 03:01 s-rog

@sheinb perhaps this is helpful? https://github.com/krassowski/jupyterlab-lsp/issues/375#issuecomment-761078622

s-rog avatar Jan 19 '21 06:01 s-rog

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 :-()

sheinb avatar Jan 19 '21 07:01 sheinb

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.

BobCu avatar Jan 19 '21 18:01 BobCu

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 [email protected] 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.

sheinb avatar Jan 19 '21 20:01 sheinb

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?

BobCu avatar Jan 19 '21 20:01 BobCu

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)

ryantam626 avatar Jan 23 '21 11:01 ryantam626

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/[email protected] && \ 

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

masip85 avatar Feb 02 '21 08:02 masip85

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!

sheinb avatar Feb 05 '21 17:02 sheinb

A couple of cases that produce this error:

  1. not having "jupyterlab_code_formatter": true in ServerApp.jpserver_extensions
  2. 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 sure rpy2 is using the same R environment)

ariutta avatar Feb 06 '21 00:02 ariutta

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.

ma-sadeghi avatar Mar 10 '21 13:03 ma-sadeghi

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.

ast0815 avatar Mar 26 '21 12:03 ast0815

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

nguyentuanngoc21 avatar Apr 25 '21 03:04 nguyentuanngoc21

jupyter server extension enable --py jupyterlab_code_formatter --user

Works for me.

GF-Huang avatar Jul 08 '21 04:07 GF-Huang

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

roboserg avatar Aug 12 '21 23:08 roboserg

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.

deKeijzer avatar Nov 23 '21 10:11 deKeijzer

A couple of cases that produce this error:

  1. not having "jupyterlab_code_formatter": true in ServerApp.jpserver_extensions
  2. 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 sure rpy2 is using the same R environment)

Maybe it is caused by R, because just after the installation of R in conda environment it occurs.

DatumWorld avatar Dec 08 '21 07:12 DatumWorld

Similar problem, annoying.

image

image

GF-Huang avatar Apr 15 '22 13:04 GF-Huang

My problem was the new config UI. Opening in JSON editing mode and removing/fixing default_formatter key fixed my issue.

tautrimas avatar Jun 14 '22 18:06 tautrimas

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.

ekungurov avatar Jun 30 '22 09:06 ekungurov

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.

nobodyinperson avatar Sep 05 '22 13:09 nobodyinperson

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

glinka avatar Mar 29 '23 14:03 glinka