Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyter-matlab-proxy kernel not working on Mac M1 with Ventura 13.2.1 #23

Closed
cerkut opened this issue Feb 21, 2023 · 6 comments
Closed
Assignees
Labels
answered Issue has been answered

Comments

@cerkut
Copy link

cerkut commented Feb 21, 2023

I set the jupyter-matlab-proxy on ubuntu without problems. But on Mac M1 with Ventura 13.2.1
I can only "open MATLAB" but cannot run the MATLAB kernel. In a typical use case with python 3.8 I get the following chain of errors; and the kernel dies as a result. I have tried with every python 3.7-3.10 using conda envs, but similar errors in all trials. Any suggestions?

Long list of errors on python=3.8
[I 2023-02-21 13:30:12.788 ServerApp] Kernel started: 0c741e25-1414-452e-af46-86940aeba93c
[I 2023-02-21 13:30:13.466 ServerApp] 302 GET /matlab (@::1) 0.32ms
[I 2023-02-21 13:30:13.483 ServerApp] 302 GET /matlab/get_status (@::1) 0.36ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 2023-02-21 13:30:15.779 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports
[I 2023-02-21 13:30:16.328 ServerApp] 302 GET /matlab (@::1) 0.53ms
[I 2023-02-21 13:30:16.333 ServerApp] 302 GET /matlab/get_status (@::1) 0.28ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 2023-02-21 13:30:18.811 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports
[I 2023-02-21 13:30:19.367 ServerApp] 302 GET /matlab (@::1) 0.55ms
[I 2023-02-21 13:30:19.371 ServerApp] 302 GET /matlab/get_status (@::1) 0.27ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 2023-02-21 13:30:21.845 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5), new random ports
[I 2023-02-21 13:30:22.410 ServerApp] 302 GET /matlab (@::1) 0.57ms
[I 2023-02-21 13:30:22.414 ServerApp] 302 GET /matlab/get_status (@::1) 0.29ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 2023-02-21 13:30:24.884 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
[I 2023-02-21 13:30:25.421 ServerApp] 302 GET /matlab (@::1) 0.51ms
[I 2023-02-21 13:30:25.425 ServerApp] 302 GET /matlab/get_status (@::1) 0.29ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 2023-02-21 13:30:27.913 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports
[I 2023-02-21 13:30:28.442 ServerApp] 302 GET /matlab (@::1) 0.53ms
[I 2023-02-21 13:30:28.447 ServerApp] 302 GET /matlab/get_status (@::1) 0.27ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_kernel()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 541, in init_kernel
    kernel = kernel_factory(
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/kernel.py", line 133, in __init__
    ) = mwi_comm_helpers.fetch_matlab_proxy_status(self.murl, self.headers)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/jupyter_matlab_kernel/mwi_comm_helpers.py", line 36, in fetch_matlab_proxy_status
    data = resp.json()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myMatlab/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[W 2023-02-21 13:30:30.945 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2023-02-21 13:30:30.946 ServerApp] Kernel 0c741e25-1414-452e-af46-86940aeba93c died, removing from map.
@prabhakk-mw prabhakk-mw self-assigned this Mar 9, 2023
@prabhakk-mw
Copy link
Member

Hi @cerkut

We've seen these issues resolve themselves when users create a clean python environment.
Would you please try reproducing the issue after re-creating the environment as shown below:

conda create -n myenv python=3.10 jupyterlab -y

conda activate myenv

python3 -m pip install jupyter-matlab-proxy

jupyter lab

@cerkut
Copy link
Author

cerkut commented Apr 21, 2023

Unfortunately downgrading python==3.10.1 and requests==2.23 with a reinstall did not help either.
python3 -m pip install --upgrade --force-reinstall jupyter-matlab-proxy

@cerkut
Copy link
Author

cerkut commented Apr 21, 2023

Thanks,

I created a new environment per instructions, only needed to add nbdev to pip install.

In the new environment, jupyterlab adds both MATLAB Kernel and Open MATLAB as launcher.
Open MATLAB works, but MATLAB Kernel disconnects with an error, see below

Thanks for the suggestion; I think the root error is pointing towards requests and json parsing.

Long list of errors on python=3.10 following the new myenv suggestion
[I 2023-04-21 08:42:43.329 ServerApp] Creating new notebook in
[I 2023-04-21 08:42:43.640 ServerApp] Kernel started: cdedadac-5256-49eb-9131-6625578a7a3f
[I 2023-04-21 08:42:45.106 ServerApp] 302 GET /matlab (@::1) 0.30ms
[I 2023-04-21 08:42:45.110 ServerApp] 302 GET /matlab/get_status (@::1) 0.28ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globa[I 2023-04-21 08:42:46.630 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports
[I 2023-04-21 08:42:47.153 ServerApp] 302 GET /matlab (@::1) 0.27ms
[I 2023-04-21 08:42:47.157 ServerApp] 302 GET /matlab/get_status (@::1) 0.27ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_[I 2023-04-21 08:42:49.647 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports
[I 2023-04-21 08:42:50.153 ServerApp] 302 GET /matlab (@::1) 0.29ms
[I 2023-04-21 08:42:50.157 ServerApp] 302 GET /matlab/get_status (@::1) 0.29ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_[I 2023-04-21 08:42:52.665 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5), new random ports
[I 2023-04-21 08:42:53.180 ServerApp] 302 GET /matlab (@::1) 0.57ms
[I 2023-04-21 08:42:53.184 ServerApp] 302 GET /matlab/get_status (@::1) 0.34ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_[I 2023-04-21 08:42:55.693 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
[I 2023-04-21 08:42:56.208 ServerApp] 302 GET /matlab (@::1) 0.51ms
[I 2023-04-21 08:42:56.212 ServerApp] 302 GET /matlab/get_status (@::1) 0.28ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globa[I 2023-04-21 08:42:58.718 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports
[I 2023-04-21 08:42:59.234 ServerApp] 302 GET /matlab (@::1) 0.52ms
[I 2023-04-21 08:42:59.237 ServerApp] 302 GET /matlab/get_status (@::1) 0.31ms
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_matlab_kernel/__main__.py", line 8, in <module>
    IPKernelApp.launch_instance(kernel_class=MATLABKernel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 693, in initialize
    self.init_[W 2023-04-21 08:43:01.751 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2023-04-21 08:43:01.751 ServerApp] Kernel cdedadac-5256-49eb-9131-6625578a7a3f died, removing from map.
[W 2023-04-21 08:43:43.648 ServerApp] Timeout waiting for kernel_info reply from cdedadac-5256-49eb-9131-6625578a7a3f
[E 2023-04-21 08:43:43.648 ServerApp] Uncaught exception GET /api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=5430fd0e-445b-40ad-a8a4-55aecac1517e (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=5430fd0e-445b-40ad-a8a4-55aecac1517e', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 67, in get
        await super().get(kernel_id=kernel_id)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 272, in get
        await self.ws_connection.accept_connection(self)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 862, in accept_connection
        await self._accept_connection(handler)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 902, in _accept_connection
        self.selected_subprotocol = handler.select_subprotocol(subprotocols)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 86, in select_subprotocol
        preferred_protocol = self.connection.kernel_ws_protocol
    AttributeError: 'NoneType' object has no attribute 'kernel_ws_protocol'
[E 2023-04-21 08:43:43.674 ServerApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.54"
    }
[E 2023-04-21 08:43:43.674 ServerApp] 500 GET /api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=5430fd0e-445b-40ad-a8a4-55aecac1517e (dfbfe586bc664f26b5d31de1bea6bb53@::1) 60028.10ms referer=None
[W 2023-04-21 08:43:43.956 ServerApp] Timeout waiting for kernel_info reply from cdedadac-5256-49eb-9131-6625578a7a3f
[E 2023-04-21 08:43:43.956 ServerApp] Uncaught exception GET /api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=fd2665dc-69c3-4a91-8482-62280e0cf7a1 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=fd2665dc-69c3-4a91-8482-62280e0cf7a1', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 67, in get
        await super().get(kernel_id=kernel_id)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 272, in get
        await self.ws_connection.accept_connection(self)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 862, in accept_connection
        await self._accept_connection(handler)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/tornado/websocket.py", line 902, in _accept_connection
        self.selected_subprotocol = handler.select_subprotocol(subprotocols)
      File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 86, in select_subprotocol
        preferred_protocol = self.connection.kernel_ws_protocol
    AttributeError: 'NoneType' object has no attribute 'kernel_ws_protocol'
[E 2023-04-21 08:43:43.976 ServerApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.54"
    }
[E 2023-04-21 08:43:44.026 ServerApp] 500 GET /api/kernels/cdedadac-5256-49eb-9131-6625578a7a3f/channels?session_id=fd2665dc-69c3-4a91-8482-62280e0cf7a1 ***@***.***) 60021.77ms referer=None
[I 2023-04-21 08:44:43.550 ServerApp] Saving file at /Untitled.ipynb

@prabhakk-mw
Copy link
Member

Hi @cerkut

Thank you for trying that out!

A bit more context in terms of whats going on here:

  1. When the kernel launches, it attempts to communicate with matlab through the endpoint : /matlab/get_status
  2. For some reason, it seems like that endpoint is not returning a valid JSON object.
  3. You had previously said that the matlab web desktop works when opened through the "Open MATLAB" button.

Could you please give the outputs of the following commands:

  1. Launch the notebook and click on "Open MATLAB"
  2. Login and start the MATLAB desktop
  3. From the MATLAB command prompt execute the following commands:
>> !jupyter server list

>> !jupyter notebook list

>> !env     
  1. Once MATLAB is running, leave that tab open and navigate back to your JupyterLab interface and click on "Kernel -> Shut down all Kernels"
    image

  2. Click on "MATLAB Kernel" to launch a new kernel

  3. Attempt to run the following command:

>> ver

Please verify that the kernel either works or fails?

  1. And then finally from your system terminal
$ jupyter server list
# Sample output:
Currently running servers:
http://localhost:8889/?token=3dabb9aa8ec0aba66f2f5fd70a213accfeb1c2d1e2adda20 :: 

$ curl -L <Fully Qualified Domain Name of machine on which jupyter server is running>:<port>/matlab/get_status?token=<get token from previous output>

#for example:
curl -L localhost:8889/matlab/get_status?token=3dabb9aa8ec0aba66f2f5fd70a213accfeb1c2d1e2adda20
*Please share the output*
# Sample output:
{"matlab": {"status": "up", "version": "R2023a"}, "licensing": {"type": "MHLM", "emailAddress": "[email protected]", "entitlements": [{"id": "11112222", "label": "MATLAB - Staff Use", "license_number": "12312312"}], "entitlementId": "898989"}, "loadUrl": null, "error": null, "wsEnv": ""}

# where **3dabb9aa8ec0aba66f2f5fd70a213accfeb1c2d1e2adda20** was the unique token set for my notebook server

Thank you for your continued support with debugging this issue with us!

Look forward to your responses....

@prabhakk-mw
Copy link
Member

Hi @cerkut

Further investigation leads us to believe that the issue is most likely related to Jupyter's Password Authentication mechanism.

Would you please :

  1. Delete the file: $HOME/.jupyter/jupyter_server_config.json​
  2. Launch a new notebook server
  3. Launch MATLAB Kernel

If that works, then it verifies that Password based authentication prevents the MATLAB Kernel from communicating with MATLAB.

Kindly confirm.

@prabhakk-mw prabhakk-mw added the answered Issue has been answered label Apr 27, 2023
@cerkut
Copy link
Author

cerkut commented Apr 28, 2023

That's it!
I have previously set password access to lab/notebooks. Removing $HOME/.jupyter/jupyter_server_config.json​ reverted the default token access, and now it works. However, I understand (and verified) that only the token access is supported, I´ll close this issue and open a feature-request to support password authentication: https://jupyter-server.readthedocs.io/en/latest/operators/security.html Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Issue has been answered
Projects
None yet
Development

No branches or pull requests

2 participants