Rather than a question, this is a simple trick I found myself that might be useful for the whole community. I couldn’t find this information anywhere posted, hence sharing it here.
It is actually possible to run a jupyter notebook inside vscode. With the Python language vscode extension, you will be able to create new Jupyter notebooks inside vscode. Once a new notebook is created you can go and change the kernel to Julia. Now in the left bottom of your vscode window, you will see option to change the Interpreter. Click on it and point it to your julia.exe file.
You are good to go!
If you know better workarounds, please share it here.
PS: I really wish I could run Pluto notebooks inside vscode
After selecting ~/.julia/conda/3/bin/python as the interpreter, I get a message popup saying “Python 3.7.7 64-bit (‘3’: conda) requires ipykernel to be installed.”
I haven’t tried doing it with the julia installed kernel. Did you try out jupyter notebooks with that conda installation without vscode? For example, does GitHub - JuliaLang/IJulia.jl: Julia kernel for Jupyter would fine?
If you do the notebook() call once, I bleieve that IJulia should install most or all of the dependencies?
This didn’t work out of the box for me. For some reason my Julia kernelspec became corrupted (either through IJulia installation process or through VS Code extension updates). So as an additional step I had to ensure that the Julia kernel which Jupyter lists (and which VS Code will access) was set to the right Julia executable. You can do this by running jupyter kernelspec list, navigating to the directory of the Julia kernel you plan on using and editing the path in the kernel.json file. This path should be the same as the Julia path you may have provided in your VS Code user settings for the Julia extension.
VS code insider (the stable version does not work yet, see this blog) My version is insiders v 1.53.0
Jupyter extension in VS code
Julia extension in VS code (I also installed the insider version but don’t think it is necessary). This extension is required for syntax highlighting and IntelliSense.
I am using Julia 1.6.0 beta, but Julia 1.5 also worked.
Microsoft told me that the vscode insiders shouldn’t be required for the jupyter support.
BTW, I tested a few days ago and it all works perfectly fine without any conda or Python at all (i.e no need to install jupyter via Python , and it might even make things more fragile)
You are right. I just tested the latest stable version 1.52.1. The code can run normally. But the UI interface of the notebook is still the old one, and, even worse, the syntax highlighting is invalid.
I am currently on the stable version 1.53.2 of VSCode with Julia 1.5.3 and I have the exact same issues with it as described by @Shuhua (edit: platform is Windows 10): Code runs, but no syntax highlighting and also only old UI.
Installed versions:
Again, with the current VS Code Insider version this works. Kinda. The syntax highlighting in many cases seems broken, especially string interpolations.
Note the 2pi marked red as well as the syntax highlighting for the string interpolation being broken.
All those things work in regular .jl files in VS Code however:
Out of interest I tried the string interpolation in nteract as well and here it was completely broken too (but in a different way):
Am I missing something? Is there currently any notebook frontend for Julia, that provides correct syntax highlighting?
They indeed were very responsive. For everyone encountering the same issues: My problem with the insiders syntax highlighting was, that even though the Julia kernel was used and run multiple times, the syntax highlighting was set to Python. In insiders you can now change this when you hover over a cell.
The issue with the current version of VS Code seems to be an old one and already reported by @jlperla - he wrote the solution to this down here: Add configuration files for code highlighting · Issue #1620 · julia-vscode/julia-vscode · GitHub (I haven’t tested this yet though, since I like the new interface of VS Code Insiders better anyway. I might test it, if I encounter any sever bugs with Insiders) - I hope this will be a non-issue in a few months when the Insiders version of the Jupyter implementation becomes standard.