Closed davide84 closed 4 years ago
Hi,
Same issue here. I am trying to dig up a bit. Output of the python -m matlab_kernel.check
seems off:
Matlab kernel v0.16.9
Metakernel v0.27.0
Python v3.7.9 (default, Aug 31 2020, 12:42:55)
[GCC 7.3.0]
Python path: /home/buschbapti/anaconda3/envs/lectures/bin/python
Connecting to Matlab...
Matlab connection established
Matlab Kernel
None
Kernel is installed and listed correctly. But when trying to kill the notebook it gives
[I 21:37:59.478 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel ba286f07-f73c-4e4d-bdc7-53707f37c24f restarted
[E 21:37:59.479 NotebookApp] Exception in callback <bound method KernelRestarter.poll of <jupyter_client.ioloop.restarter.IOLoopKernelRestarter object at 0x7f8b22c54d90>>
Traceback (most recent call last):
File "/home/buschbapti/anaconda3/envs/lectures/lib/python3.7/site-packages/tornado/ioloop.py", line 907, in _run
return self.callback()
File "/home/buschbapti/anaconda3/envs/lectures/lib/python3.7/site-packages/jupyter_client/restarter.py", line 113, in poll
self.kernel_manager.restart_kernel(now=True, newports=newports)
File "/home/buschbapti/anaconda3/envs/lectures/lib/python3.7/site-packages/jupyter_client/manager.py", line 442, in restart_kernel
self.shutdown_kernel(now=now, restart=True)
File "/home/buschbapti/anaconda3/envs/lectures/lib/python3.7/site-packages/jupyter_client/manager.py", line 383, in shutdown_kernel
self._kill_kernel()
File "/home/buschbapti/anaconda3/envs/lectures/lib/python3.7/site-packages/jupyter_client/manager.py", line 487, in _kill_kernel
raise RuntimeError("Cannot kill kernel. No kernel is running!")
RuntimeError: Cannot kill kernel. No kernel is running!
So somehow I think the kernel does not actually start correctly. Any help would be appreciated. In the meantime @davide84 which other kernel you successfully run? I was using matlab_kernel with Matlab2019b and it was working fine so I suspect something is wrong with this new version.
I currently run imatlab https://github.com/imatlab/imatlab. It has not seen updates in months, while Matlab 2020b just came out a few days ago... it probably isn't some radical change from Mathworks, rather something small that matlab_kernel relied upon.
I can't test Matlab2019b nor 2020a because they do not support Python 3.8, but I believe they are working - there's a lot of material on the Internet.
Hi,
I see similar when upgradingour Jupyter environment from python/3.7 R2019b to python/3.8 R2020b (mtalb_kernel is gh HEAD, jupyterlab is 1.1.0). Kernel apparently starts, but no output is returned to the
notebook. The matlab_kernel.check
output:
$ python -m matlab_kernel.check
Matlab kernel v0.16.9
Metakernel v0.27.0
Python v3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0]
Python path: /apps/jupyterhub/2020-10-09/miniconda/bin/python
Connecting to Matlab...
Matlab connection established
Matlab Kernel
<30 sec+ pause, follwed by>
None
Inspection of the check
code reveals that the call m.do_execute_direct('disp("hi from Matlab!")')
is returning None
, but not throwing any exception.
Further debugging shows that _execute_async
is receiving a SyntaxError
exception:
Traceback (most recent call last):
File "./test.py", line 7, in <module>
print(m.do_execute_direct('disp("hi from Matlab!")'))
File "/apps/jupyterhub/2020-10-09/miniconda/lib/python3.8/site-packages/matlab_kernel/kernel.py", line 99, in do_execute_direct
retval = self._execute_async(code)
File "/apps/jupyterhub/2020-10-09/miniconda/lib/python3.8/site-packages/matlab_kernel/kernel.py", line 257, in _execute_async
future = self._matlab.eval(code, **kwargs)
File "/apps/jupyterhub/2020-10-09/miniconda/lib/python3.8/site-packages/matlab/engine/matlabengine.py", line 53, in __call__
background = enginehelper._get_async_or_background_argument(kwargs)
File "/apps/jupyterhub/2020-10-09/miniconda/lib/python3.8/site-packages/matlab/engine/enginehelper.py", line 17, in _get_async_or_background_argument
raise SyntaxError(pythonengine.getMessage('AsyncWillDeprecate'))
SyntaxError: the 'async' keyword will be removed in a future release. Use 'background' instead
I then changed asyc
at kernel.py:256 to background
, and it works.
Confirmed that @mj-harvey solution is working. Good catch! Maybe you should do a PR for that one.
Thanks for the help. Cheers.
Works for me as well, many many thanks to @mj-harvey!
I can do the PR if needed.
Thanks, all! Anyone want to make a PR?
Pull request is there... :)
Hi, I have a setup with Ubuntu 20.04 server (headless), Jupyterhub and Matlab 2020b. I installed the kernel as per instructions (see below) and it seems to run. The kernel is listes among the available kernels, I can open a new notebook and the syntax is properly highlighted. However after a cell is successfully run there is no output, e.g. running disp('Hello World') will trigger a [*] and then [1] and finally a new empty code section below, without any output. There are no error messages in the syslog, only successful (200) HTTP requests.
I installed another matlab kernel and that works, that make me think me that both Jupyter and Matlab should be fine. However from the documentation matlab_kernel seems to have a better management of the images and I would like to use it instead :-)
I installed the kernel as follows: first the package:
and then the engine:
procedure taken from https://am111.readthedocs.io/en/latest/jmatlab_install.html