jupyterlab_code_formatter icon indicating copy to clipboard operation
jupyterlab_code_formatter copied to clipboard

v1.4.1 not working with Jupyterlab 2

Open jamesmyatt opened this issue 4 years ago • 7 comments

When I install v1.4.1 of jupyterlab_code_formatter with v2.2.9 of Jupyterlab, then I am unable to enable the server extension.

conda create --name jl-jcf --channel conda-forge --yes jupyterlab=2 python=3.8 nodejs jupyterlab_code_formatter isort black
conda activate jl-jcf
jupyter serverextension enable --py jupyterlab_code_formatter
Traceback (most recent call last):
  File "C:\tools\miniconda3\envs\jl-jcf\Scripts\jupyter-serverextension-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\notebook\serverextensions.py", line 291, in start
    super().start()
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\jupyter_core\application.py", line 243, in start
    self.subapp.start()
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\notebook\serverextensions.py", line 208, in start
    self.toggle_server_extension_python(arg)
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\notebook\serverextensions.py", line 197, in toggle_server_extension_python
    m, server_exts = _get_server_extension_metadata(package)
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\notebook\serverextensions.py", line 325, in _get_server_extension_metadata
    m = import_item(module)
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\traitlets\utils\importstring.py", line 38, in import_item
    return __import__(parts[0])
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\jupyterlab_code_formatter\__init__.py", line 4, in <module>
    from .handlers import setup_handlers
  File "C:\tools\miniconda3\envs\jl-jcf\lib\site-packages\jupyterlab_code_formatter\handlers.py", line 3, in <module>
    from jupyter_server.base.handlers import APIHandler
ModuleNotFoundError: No module named 'jupyter_server'

Obviously, Jupyterlab 2 does not install jupyter_server.

Using jupyterlab=2 and jupyterlab_code_formatter<1.4 seems to work fine.

conda list

# packages in environment at C:\tools\miniconda3\envs\jl-jcf:
#
# Name                    Version                   Build  Channel
argon2-cffi               20.1.0           py38h294d835_2    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     20.3.0             pyhd3deb0d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.1                      py_0    conda-forge
bleach                    3.2.1              pyh9f0ad1d_0    conda-forge
brotlipy                  0.7.0           py38hab1e662_1001    conda-forge
ca-certificates           2020.12.5            h5b45459_0    conda-forge
certifi                   2020.12.5        py38haa244fe_1    conda-forge
cffi                      1.14.4           py38hd8c33c5_1    conda-forge
chardet                   4.0.0            py38haa244fe_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cryptography              3.3.1            py38hd8c33c5_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
importlib-metadata        3.3.0            py38haa244fe_2    conda-forge
importlib_metadata        3.3.0                hd8ed1ab_2    conda-forge
ipykernel                 5.4.2            py38h7b7c402_0    conda-forge
ipython                   7.19.0           py38hc5df569_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.18.0           py38haa244fe_1    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                3.2.0                      py_2    conda-forge
jupyter_client            6.1.7                      py_0    conda-forge
jupyter_core              4.7.0            py38haa244fe_0    conda-forge
jupyterlab                2.2.9                      py_0    conda-forge
jupyterlab_code_formatter 1.4.1              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         1.2.0                      py_0
libsodium                 1.0.18               h8d14728_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
markupsafe                1.1.1            py38hab1e662_2    conda-forge
mistune                   0.8.4           py38h294d835_1002    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
nbclient                  0.5.1                      py_0    conda-forge
nbconvert                 6.0.7            py38haa244fe_3    conda-forge
nbformat                  5.0.8                      py_0    conda-forge
nest-asyncio              1.4.3              pyhd8ed1ab_0    conda-forge
nodejs                    15.3.0               h57928b3_0    conda-forge
notebook                  6.1.6            py38haa244fe_0    conda-forge
openssl                   1.1.1i               h8ffe710_0    conda-forge
packaging                 20.8               pyhd3deb0d_0    conda-forge
pandoc                    2.11.3.2             h8ffe710_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.8.1              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       20.3.3             pyhd8ed1ab_0    conda-forge
prometheus_client         0.9.0              pyhd3deb0d_0    conda-forge
prompt-toolkit            3.0.9              pyha770c72_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.7.3              pyhd8ed1ab_0    conda-forge
pyopenssl                 20.0.1             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyrsistent                0.17.3           py38h294d835_1    conda-forge
pysocks                   1.7.1            py38h9bdc248_2    conda-forge
python                    3.8.6           h7840368_4_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.8                      1_cp38    conda-forge
pywin32                   228              py38h1e8a9f7_0    conda-forge
pywinpty                  0.5.7            py38h32f6830_1    conda-forge
pyzmq                     20.0.0           py38h7a0e47e_1    conda-forge
requests                  2.25.1             pyhd3deb0d_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                49.6.0           py38h9bdc248_2    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h8ffe710_0    conda-forge
terminado                 0.9.2            py38haa244fe_0    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tornado                   6.1              py38h294d835_0    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
urllib3                   1.26.2             pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_2    conda-forge
vs2015_runtime            14.28.29325          h5e1d092_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
win_inet_pton             1.1.0            py38h32f6830_1    conda-forge
wincertstore              0.2             py38haa244fe_1006    conda-forge
winpty                    0.4.3                         4    conda-forge
zeromq                    4.3.3                h0e60522_3    conda-forge
zipp                      3.4.0                      py_0    conda-forge

jamesmyatt avatar Jan 07 '21 13:01 jamesmyatt

In line with other projects, I think it's probably OK to mention this in the installation instructions, rather than to change the code to work with both.

jamesmyatt avatar Jan 08 '21 21:01 jamesmyatt

Actually, looking at setup.py, I think this is a conda package problem.

edit, i.e. setup.py says 1.4.1 requires jupyterlab~=3.0, but the conda-forge package must say any version of jupyterlab.

jamesmyatt avatar Jan 08 '21 22:01 jamesmyatt

I have also run into this error when I was trying to install jupyterlab_code_formatter install jupyter_server may can solve.

conda install -c conda-forge jupyter_server

then

jupyter serverextension enable --py jupyterlab_code_formatter

gives

Enabling: jupyterlab_code_formatter
- Writing config: C:\Users\sssimonyang\.jupyter
    - Validating...
      X is jupyterlab_code_formatter importable?

I initially think it was solved. But when I opened jupyterlab and found

Juypterlab Code Formatter Error 
Unable to find server plugin version, consider upgrading.

After checking I found that it was due to extension version is not same as package version. If the version is same. It will give

Enabling: jupyterlab_code_formatter
- Writing config: C:\Users\sssimonyang\.jupyter
    - Validating...
      jupyterlab_code_formatter  ok

sssimonyang avatar Jan 10 '21 07:01 sssimonyang

Sorry I missed this while working on other issues. Is there still an issue here? You guys seem to have figured it out yourselves :smile:

ryantam626 avatar Jan 23 '21 11:01 ryantam626

The main problem for me is that the conda-forge package metadata is wrong. For <v1.4, it requires jupyterlab <3, and for >=v1.4 it requires ~=3.

https://github.com/conda-forge/jupyterlab_code_formatter-feedstock/blob/master/recipe/meta.yaml

You might need to get the metadata for the previous releases patched too:

https://conda-forge.org/docs/maintainer/updating_pkgs.html?highlight=branch#removing-broken-packages

jamesmyatt avatar Jan 25 '21 10:01 jamesmyatt

In general, conda-forge feedstocks aren't necessarily maintained by the same people as the package itself. If there's a problem with the conda-forge metadata, you'll want to open an issue on the feedstock repo.

Was just skimming this repo and saw this issue, so in case it's still a problem, I hope the above helps. @jamesmyatt

jayqi avatar Feb 28 '21 03:02 jayqi

If 1.4.x is intended for jupyterlab >=3, I think it would be nice to update the documentation to mention this.

melanopsis avatar Jul 02 '21 18:07 melanopsis

Closing due to inactivity.

P.S. I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), so if you are to re-open another issue, I would be grateful if you could wait until I have release 2.X.X version of this plugin. :pray: :pray:

ryantam626 avatar May 05 '23 08:05 ryantam626

I was just reviewing this earlier and came to the same conclusion. Thanks

jamesmyatt avatar May 05 '23 09:05 jamesmyatt