Quickstart with VS Code, Python and Jupyter Notebook image 26

Quickstart with VS Code, Python and Jupyter Notebook

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:

image

You then also need Jupyter backend. This is installed as a PIP package:

python3 –m pip install jupyter

Iimage

Also install the Jupyter notebook extension:

image

(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:

image

The notebook file will open like this:

image

When you try to run the notebook – or even a cell – you will get this popup:

image

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:

image

Press install to install the ipykernel package. This takes (up to) a few minutes:

image

After that, you are really ready to run the cell, the notebook and any other notebook you may create.

image

Happy coding!

:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.