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

Talk Python's Mastodon Michael Kennedy's Mastodon