Description
I am currently trying to get Matlab working on a relatively complex system (it's a shared linux server using Environment Modules where users lack many permissions).
The installation so far is:
- Matlab 2016b
- matlab python API
- Python 3.5 (anaconda)
- matlab_kernel
The python engine is installed, and users can install the matlab kernel by running python -m matlab_kernel install --user
.
However, when I actually try and open a matlab notebook from jupyter hub, I get the following error:
[W 11:45:05.048 NotebookApp] Timeout waiting for kernel_info reply from 2a4351d8-5d39-4a54-bc22-3a13e0fa3bc3
Traceback (most recent call last):
File "/software/system/anaconda/3.5/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/software/system/anaconda/3.5/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab_kernel/__main__.py", line 3, in <module>
MatlabKernel.run_as_main()
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/metakernel/_metakernel.py", line 126, in run_as_main
MetaKernelApp.launch_instance(kernel_class=cls)
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
app.initialize(argv)
File "<decorator-gen-120>", line 2, in initialize
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 454, in initialize
self.init_kernel()
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 365, in init_kernel
user_ns=self.user_ns,
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/traitlets/config/configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab_kernel/kernel.py", line 116, in __init__
self._matlab = MatlabEngine()
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab_kernel/kernel.py", line 36, in __init__
self._engine = matlab.engine.start_matlab()
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab/engine/__init__.py", line 112, in start_matlab
eng = future.result()
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab/engine/futureresult.py", line 68, in result
return self.__future.result(timeout)
File "/software/system/anaconda/3.5/lib/python3.5/site-packages/matlab/engine/matlabfuture.py", line 87, in result
handle = pythonengine.getMATLAB(self._future)
matlab.engine.EngineError: Import argument 'matlab.internal.engine.input' cannot be found or cannot be imported.
I get the same error when I try this in python:
import matlab.engine
eng = matlab.engine.start_matlab()
However, I am able to do the following:
- Start matlab in another terminal without the desktop using the following commands:
matlab -nodesktop -r "matlabrc; matlab.engine.shareEngine"
- In python, run the following:
import matlab.engine
eng = matlab.engine.connect_matlab()
I'm not entirely sure why my matlab python engine is unable to start matlab in this case. But a good workaround would be to make users start matlab first and then using that matlab.
I was therefore wondering - would it be possible to change the matlab kernel to try and connect to an existing matlab if starting matlab fails? For example changing this to a try / except statement that connects to an existing matlab if starting fails, and throwing a warning to tell the user?