-
Notifications
You must be signed in to change notification settings - Fork 36
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
Running Matlab in Jupyter Notebooks in VS Code (on Windows) #41
Comments
Hi @tylerlekang VSCode provides multiple ways to run Jupyter notebooks through VSCode. Currently the You can however start a jupyter notebook server, and then connect to it via VSCode and continue notebook development from VSCode.
jupyter lab
<snip>
To access the server, open this file in a browser:
file:///home/prabhakk/.local/share/jupyter/runtime/jpserver-1012796-open.html
Or copy and paste one of these URLs:
http://localhost:8888/lab?token=f5c87aa6e805384a82a8774ec366938bc554cd7e8462e1b7
or http://127.0.0.1:8888/lab?token=f5c87aa6e805384a82a8774ec366938bc554cd7e8462e1b7
<snip>
We are working on integrating with VSCode more, and look to enable more modes of access through Jupyter later this year. Hope this helps! Adding video demo of this process: 2023-11-17.15-27-38.mp4 |
@prabhakk-mw that works perfectly! I did not know that was an option! Maybe in the future there can be a MATLAB for Notebook extension that takes care of even needing to open the JL server in the first place, but that really is a minor inconvenience. In fact, VS Code was able to auto-detect the correct URL w/ token instead of even needing to copy/paste it from the JL terminal. The major thing that is lacking with this way currently is to have function auto-completion and information appear when you type ("IntelliSense"). This is available using the MATLAB extension when editing an .m file (though doesn't display function documentation as well as Python/Pylance extensions), but currently the only auto-complete options that populate are any existing variables or functions that have already been defined/used in the notebook. In fact, using this method addresses all three of the issues I raised for using MATLAB in Jupyter Lab In other words, building the notebook in VSC instead of JL alleviates all three of these issues. (Not sure how, but none of them happen in VSC Notebook). |
@prabhakk-mw one other minor thing for the (hopefully) future, regardless if having to manually connect to a (remote) existing Jupyter server or if VS Code will one day be able to make a direct local connection to a MATLAB kernel, there is also a "Jupyter Powertoys" extension for VS Code which allows any contextual help from the kernel to be displayed in a side panel. As of now (probably as expected), this only displays the message "No response from kernel" when running with (remote, manually connected) MATLAB kernels. |
Hi, I'm wondering how you are doing this, where is the buttons?
|
@Will-Zhao0 , I've updated my answer to include a video. |
For whatever it is worth, what I do in Windows10 is:
|
Yes @tylerlekang, you are right, one does not need to actually run anything in the JL interface. Additionally, once licensing has been carried out at least once on a machine through the JL interface, this information is cached and is re-used by the MATLAB kernel for subsequent launches. Licensing cannot be done through the VSCODE interface using the web screens as there isn't a way for us to route those screens into VSCODE. |
@prabhakk-mw it would be good if somehow it were possible for any external tool (VSC or anything) wanting to do Matlab via Jupyter could connect without having to copy the address every time and re-set the connection. Like if j-ml-proxy had a way to have a permanent ip address/port that would always redirect to the correct/current running Jupyter server. (And then even more ideal, if there were a set of commends you could send to that "middle man layer" that could view and manage the active Jupyter kernels!) I don't know if Jupyter allows such a thing to be possible, though |
We are actively working on improving our product for its usage with vscode to be seamless, and get as close as we can in terms of experience to be similar to other kernels. Stay tuned. 🙂 |
There is currently a VS Code extension for Matlab https://github.com/mathworks/MATLAB-extension-for-vscode/ so I'm not sure if this request/issue should be here or there? But that just allows you to edit a .m file fairly nicely, not run it -- in the sense of a notebook with inline outputs for each code sections. (I strongly disagree that Live Scripts give an equivalent experience to a notebook. It's not the same, and I don't particularly care for it.)
The ultimate would be to be able to run Matlab in a Jupyter Notebook in VS Code, with a nice environment (similar to Python with the Python & Pylance extensions).
Will this be upcoming? Pretty please. :) Thank you!
The text was updated successfully, but these errors were encountered: