Hey, welcome back.
In this video, you learn how to use Jupiter.
Jupiter, as I already mentioned, is a code editor.
But with some special features, you'll see exactly what those features are in this video.
So we will do two things here.
First, we will install Jupiter, and second, I'll show you how to use Jupiter to install Jupiter.
You should go to Jupiter dot org.
Note that this is with a Y.
Jupiter.
The planet is with an AI.
So once you go there, you should go to install.
Now here you can see the installation instructions.
However, these instructions are generic and they change slightly depending on your operating system.
That's why here I'll keep two operating systems open.
Here on the left, I have a Windows machine.
And here on the right, I have a mac machine.
So I'll tell you exactly what you need to change during the installation depending on your operating
system.
So if you are on Windows, Mac or Linux, you'll know exactly what you need to do to install Jupiter
correctly.
So if you are on Windows, you should go to the start menu.
And search for command prompt.
So that is my command prompt.
And if you are on Linux or Mac, you should search for the terminal.
Then on Windows, you should type in p y minus three points.
In my case, that would be 11.
So I have 3.11 installed on my computer.
In your case, it could be another version.
So whatever you have been using, you should place that version in here on Mac or Linux.
That would be Python 3.11.
Same thing goes here.
You should adjust that version.
If you don't know what version you are using, then try to press enter here.
So P -3.11 Press enter.
And if you see these arrows, that means you do have that version.
So if you see the arrows, then to exit with parentheses to go back to the terminal.
So you should be in the terminal.
Now as you see here, if you get an error, then try P -3.12 or P -3.10 or P -3.9, depending on what
you have.
Same goes for Mac, so try to search.
Yep.
Python 3.11 is available in my case, so I'll do exit parentheses to go back to the terminal.
Now that we are back to the terminal, we should do again.
P -3.11 minus M Pip install Jupiter lab.
For Mac or Linux.
That would be Python 3.11 M PIP install Jupyter lab.
So press enter there.
Press enter here.
And that installed Jupiter lab on Windows and also on Mac and Linux.
So now we are ready to start Jupiter Lab.
Now to do that, we first need to close these terminal windows.
Then you want to go to a specific directory, for example, lets me go to downloads.
So this is just a folder.
It could be any folder on your computer.
So this will be the folder where you want to create the Python files or any other associated files.
So this is the equivalent of the project directory we have in charm.
So open a folder on Mac and Linux two and then you want to go one level up that folder.
And you want to click on that folder.
So do the same for Windows.
Right click over the folder and then go to open Internal on Windows and on Mac, you should do the same
right click, go to services and then go to new terminal at folder on Linux.
You should also see here open in terminal or something like that.
So a new terminal folder and that will open the terminal program.
Pointing at that particular folder.
Downloads.
No, We will start.
Jupiter lab and Jupiter lab will open in this particular directory, so Jupiter lab can be opened from
the command line using the Jupiter.
Minus lab command.
Same here.
Jupiter minus lab command.
So press enter.
Press enter.
That will open Jupyter lab on your browser.
So here is on Windows and here is on Mac.
And this opens in that particular folder downloads folder in my case.
Then what you want to do is you want to create a Jupyter document by clicking on that icon.
So this icon here and from now on, the instructions on Mac and Linux and Windows are the same.
So I'll just use only one of these operating systems.
So that's a Jupyter document.
And this here is a Jupyter cell.
And inside cells we can write Python code such as print Hello.
To execute the code, you should press control, enter on Windows and Linux or command enter on Mac.
That will execute that code and you'll get the output instantly.
You can add more code in that cell by clicking over the cell and then press enter and adds high.
For example, press enter to add a new line.
Hi again.
And to execute the cell again, you want to press control, enter or command center.
So there you go.
We get the results of all the scripts.
So we have a script here written in a cell, and we can create multiple such scripts by pressing this.
Plus I can.
Or you could just press be on your keyboards.
But first, before you press B, you should press escape because currently our focus, the cursor focus
is inside the cell.
So press escape and then press B that will create a new cell.
Then press enter to enter that new cell.
And here you can write code again.
Hi.
I'm another cell control enter to execute it again.
Escape be.
Enter and you can continue writing code like that.
Now you would ask, What's the catch here?
What is the benefit of this Jupyter notebook?
Well, as you can see, this is very similar to the Python interactive shell.
So you can code quickly and you can keep your code manageable, organized in separate cells.
The big difference here, though, between a Python interactive shell.
You know, the python shell where we coast here.
So this is the python shell.
Just wanted to remind you, in case you don't know what I'm talking about.
So the big difference between that python shell and this Jupyter notebook is that once you close the
python shell, the code you wrote there is lost.
And this is not the case with Jupyter because here we have created an.
Untitled that IP Y and B file.
So this is an actual file.
And if you go to the folder, in my case downloads where we started Jupiter Lab, you'll see that we
have that file actually here in this folder, Untitled.
So now what I'll do is I'll give you a demonstration.
I'll close.
This file and to close it, you can either close it here or if you want to stop Jupyter, you want to
go to the terminal to the command prompt where we started Jupiter Lab.
You see here I rang this command and this window should be kept open for Jupiter lab to run.
If you want to stop Jupiter lab, then you want to close this window.
So that means we have stopped Jupiter.
So even if you try to run this now, like to run some code, like print ten.
Jupiter lab will not allow to do that.
So we have lost the connection so we can close this page and to open again.
Jupiter Lab.
Maybe you start working tomorrow again.
You won't again to open the terminal first, the command prompt.
And then Jupiter minus lab press enter that will open the browser automatically.
Ah, but you should be careful here, because what I did actually is I started Jupyter Lab and this
directory users slash a s.
Therefore, what I see here are.
Folders and files of that particular directory.
So these, for example, are files I've created earlier in that directory.
User slash as.
So if you want to open Jupyter lab in one particular directory, again, what you should do is you should
close this window.
Go to that particular directory so downloads and do the same process that I showed you.
So right click and go to open internal or on Mac.
That would be services and then open folder in terminal.
And then here you should run Jupyter lab again.
This time.
That session should be pointing to that downloads folder where we have these two files and to open the
previous document we were working on, you should right click it and that will open the same code we
were been working on.
It's a good idea to give this a name, so right click over that file, go to rename and just give you
the name.
So as you can see, Jupyter Lab is like a hybrid between a Python interactive shell and an ID.
Now you might ask, Well, can we use Jupiter Lab instead of punch on for any project?
The short answer is no, you cannot do that because when you write a program in Python, you might have
several Python files.
So these are that P files, but Jupyter creates an IP Y and B file, so that is not a dot P file.
This is a notebook file where you write this kind of code in different cells.
So Jupyter is designed to be used when you simply want to explore some code.
And this is particularly useful when you want to load some data with pandas and then print out the first
ten rows, perhaps do an average of a column of the dataframe, maybe plot a graph.
You can also plot graphs here on Jupyter Notebook, which is also one of the differences between a Jupyter
notebook and the python shell.
So you can see the graphs in here.
So in the next video we will use Jupyter Lab again with Pandas.
We will explore some datasets and I'll teach you Pandas in depth so you will learn some advanced concepts
of pandas, and then we will use pandas for our API.
But before we use pandas with our API, we want to explore the data sets in Jupyter.
So let's do that in the next video.
Thanks.