Jupyter Notebooks in VS Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
for those who didn't know visual studio code  supports working with jupyter notebooks natively   and through python code files so for anyone who  would like to i'm just going to take you through   the basics of setting up a jupyter notebook and  managing that notebook within visual studio code   so first up then let's go over to the extensions  here and search for jupiter you can see that i've   already found it so just type in jupiter that will  then give you a nice little list and hopefully one   of them will be this here jupiter by microsoft  and this provides us jupiter notebook support   one of the benefits of utilizing jupiter  notebook inside visual studio code we get   the most best of both worlds jupiter  and all the tools provided by the ide   i have used this extension quite extensively and  it's fair to say as you can see from the reviews   here that it isn't quite flawless in how it works  if you're being quite expansive with your code   um you'll find maybe that you will have some  problems it might be a little bit hit and miss   but it's definitely worth having a go if  you wanted to integrate jupiter notebooks   within visual studio code so two ways we can  start utilizing jupyter notebooks once we've   installed that extension is we can just start  creating files so here let's just go ahead and   create a new file and that of course is going  to need the ipy nb file extension and straight   away you can see as soon as you created  that new file we then have the interface   which correlates to jupyter notebooks in addition  you can just go over to and you can't use this uh   in to view that and open up your command palette  you can use the shortcut of course and then from   here we can also now utilize the command so if  we type in jupiter you can see that we've got   a number of different pre-created commands so  new notebook and we're off so just press save   and then we can save it wherever we need to  save it so two ways of creating a new notebook   so if you are completely new to this game you  are going to need python installed so if you   haven't already installed python you're going  to need to install python on your machine to get   this working of course so once you have installed  python typically in your notebook you'll probably   want to utilize a virtual environment  or work within a virtual environment and   depending on whether you're using windows or mac  will depend on how that is set up there are some   tutorials if you have a look in the channel not  too long ago from this tutorial where i take you   through that process on windows and mac so here  in mac we can type and it's similar on windows   once you've installed python of course we're going  to just set up a simple virtual environment so   that's pretty much the same command on windows and  mac and then in windows sorry mac i type in source   or on windows you're just going to  type in backslash venv so source   and then source and the vmv i've used tab  there to finish that off and then on mac   it's going to be bin and activate on windows it's  going to be scripts scripts and then activate   so that's going to be the slight  difference there windows and mac   so once that's activated you can now go ahead  and store all your dependencies or requirements   so once you have got your virtual machine you  want to kind of connect that to your jupyter   notebook if you like so here up top we can select  the kernel so you can see what we've got here is a   list of different python maybe versions you have  on your machine and at the bottom here it says   vamp so you can see this folder structure to this  new vent to this new virtual environment where   python is installed and of course potentially  we want to work within that environment because   that's how we've set up our environment here we  want to work within our virtual environment so we   need to select that and now we're working from or  within that virtual environment with our notebook   so here we have a cell and you can see that if  i hover over the top or the bottom of the cell   you can see we have two options here i  can create a new cell or i can create a   new markdown cell if you like so here i can type  in typical kind of markdown so new new notebook and then once you've done press the tick and you  can see that then that creates the the markdown   and that can be done within or in between each of  the the cells the code cells that you're creating and these cells are really easy to work  with if we hover over them or click on them   and we can edit or of course delete them  so it's very easy to work with these cells   so you can see from the top nav here the  type of commands that we have available   so typically working with  with this let's just go for some simple code um so we've got two cells here  with code so we'll just go ahead and print hello   and then world so you can see we've got run all  to run everything and we're asked here to install   uh running cells in python requires package so we  need to install so just go ahead and install that   and this is kind of synonymous of utilizing this  tool within visual studio code it does provide us   these tips here in terms of what packages we might  need to install so you can see that runs and you   can see the output below so we can clear all the  outputs of the cell and we've got some additional   options here to clear these cell outputs so let's  just go ahead and clear them you can see that we   can run the cell individually by utilizing  this left run icon or the execute cell icon   and there's some more handy features over on the  right hand side here we can export this into html   python script or pdf so some nice little tools  out on the menu so like i alluded to at the start   it's not perfect um sometimes what happens  i find that the code just takes way too long   to execute and then i find myself utilizing  the interrupt to stop the process quite often   but again it depends how expansively you utilize  this i think that if you are starting to learn   code this does provide some great tools to  kind of break down components and make it   more manageable to make some simple notes  or some simple scripts that you can utilize   later in your code ultimately you're just going  to be balancing up your the pros and cons here   on how this performs for you so in terms of  managing the cells here there's quite a few   options so we can drag and um change position of  the cells on the right hand side here we've got   a number of different options uh change  cell to markdown that can be pretty handy   show what i normally turn on the actual line codes  that's pretty handy too because typically if you   do get errors it does define what what line  the area is on so that can definitely be handy   so where this might have issues with is with  other extensions installed potentially that's   where probably maybe some of the issues might  resolve from but i find generally the extensions   i use for example python that works well with  uh the notebooks and you can see that you kind   of get the best of both worlds here in that  um it provides all the kind of intellisense   and the normal options you'd get from the  other extensions that you have installed   if you are working in a very structured  way um something that's quite handy is the   the outline so let me just go ahead and say step  let's go to step one for example so i want to do   that in just close that let's go ahead and mark  down i want to use mark down here so we're going   to lower that and we go into the outline you  can see here we have step one so this kind of   gives you a nice way of generating some content  um so again let's just go for step two here   and then press ok and you can see that that's  going to produce a nice little outline and that's   going to allow us to easily navigate through the  workbook as it becomes a little bit more expansive   in addition to these features moving forward maybe  you want to start for example variable watching   so we can access variables and other information  here once you start working with data for example   rendering plots you will find that they will  get rendered under the cell and you can go   ahead and easily save them in different formats  so i do get quite a lot of questions about you   know what tools are using what extensions are  you using so this type of tutorial really is   for me to point people towards these tutorials  when they when i do get asked those questions   so they can start to have a look at the tools  i'm using and also how to start using them   so i do hope there was some value there for you  any questions any queries any problems just leave   a comment in the description and i  hope to see you in another tutorial
Info
Channel: Very Academy
Views: 59,729
Rating: undefined out of 5
Keywords: visual studio code Jupiter notebook, vscode Jupiter notebook, Jupiter notebook vscode
Id: jNk-ZmeIz6c
Channel Id: undefined
Length: 8min 59sec (539 seconds)
Published: Sat Apr 02 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.