Why I use Jupyter Lab for Python

What is Jupyter?

Jupyter lab is a great tool to use Python also in a ‘visual’ way. I reccomend it for beginners and for advanced users, because it gives you a lot of chances to experiment with your code, compare different version of your script and it’s so useful when you work with images of graphs because you can watch them right inside the notebooks (that are the files created by Jupyter lab). Jupyter lab is the evolution of Jupyter notebook (that was the evolution of IPython) and it’s worthwhile giving it a try.

How to install it?

If you want to install it:

pip install jupyter lab

What makes Jupyter lab different?

There are a lot of way to write and test code, a lot of great editors. I use regularly Sublime Text 3 (my fav) and lately Visual Studio Code (for my flask blogs and I am starting using it for my glitch apps), but there is one ‘editor’ that has something unique and it’s Jupyter Lab (also known in another, previous version, as Jupyter notebook). Maybe you’ve heard of it or maybe not, with all the existing tools you can use it is easy to be lost and overwelmed wondering which one you can use.

You can use more editors or tools, depending on what is your purpose. I remember that I was really surprised and amazed when I discovered this tools, because it has some visual stuff that can make the difference for some project. It is very useful to compare different versions of the same code in the same notebooks… but wait, what are notebooks?

Jupyter notebooks

Jupyter saves files with the extension ipynb. The nb stands for notebook. In fact the code are written in the browser and in different cells of a ‘notebook’. You can run every cell that can be or not be connected to the other. In this way you can easily compare two different versions of a script.

The markdown

In the cell you can also use markdown text so that you can explain what the code does in a much more expressive way than the simple comments in the code. This is great to show to others what you are doing and for you to store ideas also.

The images

Another great thing is that you can display images right after the code to see visually the result of your code that is great when you use PIL or matplotlit, just to mention some examples

The html

Another advantage of coding in jupyter lab is that you can display html in the page, so that you can make a lot of visual improvements and utilities that are just left to your imagination. Here I will show you how you can use html in jupyter:

from IPython.display import display, HTML

display(HTML("<h1>Hello World!</h1>")

The video where I show how I am using Jupyter lab


Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.