Python for .NET Developers Transcripts
Chapter: Computational notebooks
Lecture: Installing JupyterLab

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Python really dominates the space of these computational notebooks. So we're just going to get started and the thing we need to do is
0:07 actually set up a little bit of stuff for us to do that. Now, PyCharm does have some support for notebooks but most of what we do is actually
0:17 just install and run Jupyter Lab and then work in Jupyter Lab but we're going to start by doing at least maybe we'll come back to PyCharm at the end.
0:25 So, here we are in our Python code section of the Git Repo. I'll make a directory. We also need to make sure we activate our environment.
0:41 Remember venv\scripts\activate on Windows without the dot. So we have that here and we need to install Jupyter. Notice that in the j's
0:51 we don't have a Jupyter so we're going to install a couple of things. Start by installing, jupyter. Alright, that's a good start.
1:02 We've got a bunch of dependencies installed there. Also need Jupyter Lab. We can run this by saying just, jupyterlab. So, it does a bunch of stuff
1:14 Kicks off our browser and logs us in. If you are super quick you be able to see like Hey, it's using this temporary token
1:21 to make sure that we're allowed to access it. and then it does some redirects over to it. So right now we've got our notebook section over here.
1:29 Let's go in there and we can add all sorts of new things. I could even click that or I could just go here and say Your notebook, if for some reason
1:39 you're remoted into the system you could fire up a terminal in say pip list or do various thing like this actually.
1:47 See where we are. Go to our notebooks. Right, so we can do arbitrary stuff in the terminal here but we just want to create one
1:55 of these new notebooks, for now. And now notice it says What kernel do you want to use? This is a little bit tricky because
2:03 we installed Jupyter into our virtual environment but this Python 3 even thought it looks like it's going to be okay turns out to be not what we want.
2:12 Let's name this notebook something like References, or something to that affect. So we're going to go and do some work with this
2:20 and I'll tell you about the problem we're going to solve. We're going to do some cool analysis and real-time interactive exploration
2:27 of some data and then visualize it. Like, that's the role of these things but I just want to show you something really simple.
2:33 Well, first of all, we could actually come up with like just let me show you how it runs. y=2, we could run this little section
2:40 and then down here we could come up and say x+y let's put 7xy. We run that and we get an answer, like so.
2:49 When you just explore we can import some libraries. Start working with them. So this is all well and good except for, watch this.
2:58 Going to say, No no no! Problem! Problem here! We don't have this library! So, we're going to need a couple of libraries
3:03 and this Python here if we say, import sys then we say Sys.path Python path. Oh we got to get rid of this. Notice, what working version
3:15 of Python we're using. We're using just the system Python and then the path obviously goes here but it, get it to print out which Python we're using
3:24 it's turns out that this is the system Python not the Python that we're wanting to work with. This is not our virtual environment Python.
3:31 With everything we're installing. So, in order to finish setting this up we do need to do one more step to tell Jupyter, Hey! I want you to register
3:39 an option for us to select here that is our virtual environment. but once we get that done we can just go up here and start typing some code.
3:46 So far it's not very impressive because it's just numbers as a calculator, basically but we're going to be able to improve upon this
3:53 and put all sorts of cool interactive graphics and stuff up here.


Talk Python's Mastodon Michael Kennedy's Mastodon