” How to Use Pluto.jl (and Jupyer) in VSCode: A Step-by-Step Guide to Interactive Computing in Julia”

pluto notebook in vscode editor

When I just started to work with Julia Language, I developed a decent workflow and had favourite tools to get the work done. I wrote about it a while back in this blog article “My preferred Julia IDE after 3 months of coding.”

Since then I have polished my workflow so that it is as frictionless as possible for my research project. I still love VSCode and use it exclusively to write my code. However, I learned that using Jupyter Notebook from within VSCode (instead of the web version) is even more convenient. Especially that I now use VSCode not only on my own laptop (MacBook Pro M1), but also have it on my workstation on campus. That way I can use the remote ssh to log in to my computer at uni and use it to develop and run any GPU code that I need.

To be honest, I abandoned the use of Pluto.jl notebooks for Julia because I could not use them from within VSCode, even though I loved some of the features it has, especially how it displays the data structures of the cell output.

I was pleasantly surprised recently to discover that there is now an extension for Pluto.jl in VSCode, that allows me to use and run it from within the editor. That way I can use it on both computer, locally on my Mac and remotely on the GPU workstation.

So, let see how this works.

First, if you are new to using Julia, here is a brief overview of what it is and how to use it. Otherwise, please feel free to skip right to the section about Pluto in VScode.

JuliaLang and how to write Julia code

Julia is a high-level, high-performance programming language for numerical and scientific computing. It was designed to be fast, dynamic, and user-friendly.

There are several ways to use Julia. First of all, you need to install it on your computer. You can download the latest version of Julia from the official website (julialang.org).

Using Julia REPL.

Start the REPL: REPL stands for Read-Eval-Print Loop and is the Julia interactive shell that allows you to enter and execute Julia commands. Plain and simple, but not efficient for larger projects.

Using a code editor.

Writing Julia code using a code editor is a great way to improve your productivity and efficiency when programming in Julia. Here are the steps to write Julia code in a code editor:

Choose a code editor: There are many code editors available that support Julia, including Visual Studio Code, and Sublime Text. Choose an editor that you are comfortable with and that meets your needs. I, personally, love VSCode! In this article we will talk about it in more detail.

Install Julia extension: If using Visual Studio Code, you need to install the Julia extension to add Julia language support to the editor. For other editors, there may be a similar process to install a plugin or package that adds Julia support.

Create a new file: In your code editor, create a new file with a .jl file extension to indicate that it is a Julia file.

Write code: Start writing your Julia code in the file. Your code editor will provide syntax highlighting and code completion to help you write code quickly and correctly. VSCode also lets you to hover over any function and provides a popup window with the documentation and usage examples, which is very handy.

Run code: you can run the code directly from your code editor. Visual Studio Code has integrated terminal support, so you can run Julia code from within the editor.

Using a Jupyter Notebook from within VSCode

Using a Jupyter Notebook from within Visual Studio Code can be a powerful way to interact with and explore data in Julia. This is what I have done for a while now. Here are the steps to get started with using a Jupyter Notebook in VSCode:

Install Jupyter: You will need to have Jupyter installed on your system. If you don’t already have it, you can install Jupyter by following the instructions on the Jupyter website (jupyter.org).

Install Jupyter VSCode extension: To use Jupyter in VSCode, you will need to install the Jupyter VSCode extension. You can do this by searching for “Jupyter” in the VSCode extensions marketplace and installing the Jupyter extension.

Open a Jupyter Notebook: Once the Jupyter extension is installed, you can open a Jupyter Notebook in VSCode by clicking on the “Jupyter” icon in the VSCode activity bar and selecting “Open a Jupyter Notebook.” Or, alternitevly, you can create new file with the .ipynb extension and then choose the Julia kernel in the top right hand corner of the notebook, so that it uses Julia Language. Jupyter by default starts with the Python kernel.

Write and run code: Once your Jupyter Notebook is open, you can start writing and running code in Julia. You can use the Jupyter interface to create cells, write code, and run your code. The output of your code will be displayed directly in the Jupyter Notebook.

Using a Pluto.jl Notebook from within Visual Studio Code

Pluto.jl is a package in the Julia programming language that provides an environment for interactive computing. It is designed to be easy to use and to provide a notebook-style interface for data exploration and analysis, just like the Jupiter Notebook, but specific to Julia.

With Pluto.jl, you can write and run Julia code either in a web-based environment, which allows for easy sharing of code and results with others. The package also provides features such as automatic outputs, rich media embedding, and support for multiple languages.

Or, as of recently, you can also use Pluto.jl from within VSCode editor. Yay! It is still under development and will improve overtime, but it’s there, and it’s working, I tested.

To use Pluto.jl in VSCode, you will need to install the Julia extension in VSCode (if you don’t already have it), then open a new or existing .jl file in the editor. From there, you can run your code in a Pluto notebook by using the “Pluto: Open in Browser” command from the Command Palette or by using the key binding Cmd+Shift+P and choosing “Pluto: Open with Pluto.jl” from the drop-down option (need to scroll) on top of the window.

This integration makes it possible to use the power and convenience of Pluto.jl within the VSCode editor, giving you the best of both worlds – the ease of use of an interactive notebook with the power and flexibility of a full-fledged code editor.

So, if you prefer to use Pluto instead

of Jupyter notebooks to prototype your code, now you can do so from within a VSCode editor!

5 thoughts on “” How to Use Pluto.jl (and Jupyer) in VSCode: A Step-by-Step Guide to Interactive Computing in Julia””

Leave a Comment

Your email address will not be published. Required fields are marked *