Python for the .NET developer Transcripts
Chapter: Computational notebooks
Lecture: Registering the virtual environment with Jupyter

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, let's exit out
0:01 of our little running environment here.
0:04 It's important our virtual environment is active
0:07 so we ask, which Python?
0:08 It's the one in our virtual environment.
0:10 So what we want to do is we're going to say pip ipykernel.
0:14 It's going to let us control the system just a little bit
0:17 and register things, like our virtual environment.
0:20 Alright, looks like that was already installed.
0:21 That's great. So then we want to run that module
0:26 so you can say python -m to run a module
0:29 then it's that one. I almost have probably copied.
0:32 See I want to register something for the user
0:35 and the name is going to be course_env.
0:38 Alright, so what we're going to do is tell IPython
0:41 or Jupyter about the virtual environment
0:43 that Python lives at, which is active right now
0:46 so you got to make sure you have
0:47 your virtual environment active.
0:48 Oh, I forgot to --install here.
0:50 Alright, a straight up install.
0:53 Here we go, install this over here.
0:57 Let's see what happened.
0:58 If we look at that /kernel.json
1:01 it basically says here is the Python you're going to use.
1:06 Its display name is course_env and it's Python.
1:09 So we go back here and we just run JupyterLab again.
1:12 It opens up, let's close this older one.
1:14 It'd probably refresh, but let's not mess with it.
1:17 Let's open this up
1:18 and now, if we go an change it, look, here's our course_env.
1:22 Woo-hoo. Let's go and do one more thing.
1:28 Let's go ahead and pip install feedparser
1:31 which is a thing that we're going to want to use.
1:33 Notice it's going to install into our virtual environment.
1:36 This is a way for dealing with RSS feeds.
1:38 We're going to be working with one of those in just a second
1:40 but it also just let us test, hey, that this thing worked.
1:43 So pip list up here.
1:45 We're getting a lot of stuff with all the dependencies here
1:48 but notice we have feedparser like so.
1:51 And I guess we got to restart things.
1:56 And Jupyter, once again, over here
1:58 and now, we can go to our course environment.
2:00 Forget the stuff we want to import.
2:03 Feedparser and just make sure everything's working.
2:05 Oh yes, it's working really well.
2:12 We can go over here and tell it to parse a URL.
2:15 Let's say the URL is going to be something like this.
2:18 Going to go to Python Bytes
2:19 and we want its RSS feed, which is here.
2:25 Going to be that. Check it out.
2:30 Well, apparently, that printed the entire thing.
2:34 Notice how small this is.
2:35 That's a problem because this is like a megabyte
2:37 and we got the feed and we got the title.
2:39 Let's just go print rest.getfeed.
2:46 And within there, we get a sub document or a sub dictionary.
2:50 From that, we can get the title.
2:53 Here we go, Python Bytes.
2:54 Hey, we went and downloaded it
2:56 and we turned it into this JSON document
2:59 which is pretty awesome.
3:01 So we've got our virtual environment working
3:03 with all of our dependencies installed.
3:05 They're not relying on the system one
3:08 and we've got out notebook system up and running.