Jupyter Notebook Extension in Visual Studio Code
In this article, we will see how to use Jupyter Notebook in Visual Studio code.
Jupyter Notebook has grown into a popular IDE choice. With the availability of additional kernels in addition to IPython, Jupyter Notebooks can also support Java, R, Julia and other popular programming languages besides Python. The notebook integrates the outlines of Markdown text and executable source code to empower collaborative, scalable, and repeatable team projects.
Everything has changed! With the recent release of the VS Code Python plugin in 2019, VS Code has provided native Jupyter Notebook support, allowing me to work on my notebooks without running Jupyter Notebooks. . In this article, we will discuss the basics of how to use Jupyter notebooks in VS Code.
Creating Jupyter Project notebooks:
To create a new Notebook, simply go to View -> Command Palette (⇧⌘P on Mac). After the palette appears, search for “Jupyter” and select the option “Python: Create Blank New Jupyter Notebook”, which will create a new notebook for you. For the purpose of this tutorial, I created a notebook called JupyterExample.ipynb as shown below.
Insert and delete cells:
To insert a cell, click the plus sign on the toolbar or the plus sign to the left of the cell. To delete a cell, click the delete symbol (that is, the trash can symbol) on the right side of the cell.
Switching Cell Content-Type and State:
To change the content type, click the code/markdown area in the cell. To change state, click the text entry box to put it in edit mode. Click the vertical bar to the left of the cell to switch to command mode. When you click on another cell, the previously selected cell will be deselected. The status of the cell is indicated by the vertical bar to the left of the cell.
Shortcuts in Command State:
When the cell is in the command state, as shown by the solid blue line on the left, the following shortcuts can be used.
|a||Insert a cell above the current cell|
|b||Insert a cell below the current cell|
|dd||Delete the cell|
|l||Show the line numbers|
|y||Set the content type as code|
|m||Set the content type as Markdown|
Run Code Cells:
To run the code unit, just click the triangle symbol in the code/markdown area. To run all code cells in Notebook, just click the double arrow in the top toolbar.
Although not shown in the figure above, the triangle with the up arrow in the toolbar is used to execute the code unit above the currently located cell, and the triangle with the down arrow is used to execute the code unit below the currently contained cell.
Getting the Variables Viewer:
To see the list of declared variables, simply click on the variable in the toolbar and a table will appear showing all the defined variables. If you declare a new one, it will be automatically included in the table.
Getting the Plot Viewer:
For the generated plots, we can click the chart icon in the corner of the chart output, as shown in the figure below.
In the plot viewer, you will see a toolbar at the top, which has some common functions, such as zooming in and out and saving graphs.
Saving the jupyter notebook :
You can use the Ctrl + S keyboard combination or use the save icon on the Notebook Editor toolbar to save Jupyter Notebook.
Exporting the Jupyter Notebook:
You can export Jupyter Notebook as Python (.py), PDF or HTML files. To export, just click the conversion icon on the main toolbar. Next, you will see the command panel file options.
Please Login to comment...