I have worked with Jupyter Notebooks in the past – running a server and working with the notebook in my browser. Then I learned about the support in VS Code and saw how incredibly easy it is to get started with and work in notebooks in VS Code. Even though the steps are ridiculously simple, I did not know about them before today so perhaps this article can help you a a little as well.
The steps are:
- install VS Code
- install Python 3
- install the VS Code extensions Python and Jupyter
- create a new Jupyter Notebook (text file)
- define a cell in the notebook, try to run it and
- follow the prompt to create a Python environment
- follow the prompts to install Jupyter Server package
- run the cell again once both steps are complete and you will have your notebook up and running and ready to expansion into the world of Python
I will now show you the steps in screenhots:
Assuming your operating system already has Python and Python PIP installed as well as VS Code, start VS Code.
nstall the Python extension:
You then also need Jupyter backend. This is installed as a PIP package:
python3 –m pip install jupyter
Also install the Jupyter notebook extension:
(I learned that Jupyter is short for Julia + Python + R. And I guess these are represented by the three dots in the jupyter logo.)
When installation is done, create a new File from the File menu and select the Jupyter Notebook file type:
The notebook file will open like this:
When you try to run the notebook – or even a cell – you will get this popup:
asking for a Kernel. Click on Python environment, then create an environment using the preinstalled Python runtime.
Once the Kernel is defined, another popup appears:
Press install to install the ipykernel package. This takes (up to) a few minutes:
After that, you are really ready to run the cell, the notebook and any other notebook you may create.
Happy coding!
: