Getting Started with NLP and spaCy Transcripts
Chapter: Setup
Lecture: Installing packages

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In this course, we're going to be playing around with spaCy, and we're going to be doing that from a Jupyter notebook,
0:07 but it also means that we have to install some software. So in this video, I'm just going to install all of that and walk you through
0:13 everything you need to do. First of all, you typically want to do your work inside of a virtual environment.
0:19 So what I've got here is I've got a couple of Python versions on my machine that I can go ahead and use.
0:25 You don't have to use the same version that I'm using, so for Python 3.10, that's a relatively modern enough version.
0:31 And to start a new virtual environment, I can do python3.10 -m venv. This -m is going to access a module inside of this version of Python,
0:43 and I'm going for the virtualenv module, so to say. And basically, this is a little command line application,
0:49 and I'm telling it to create a folder called venv where my virtual environment is going to reside in. So that's now created.
0:58 I can source that virtual environment folder by going to source, virtualenv bin activate. There we go.
1:07 And you can now see in the terminal that I've got my virtual environment activated. From here, I want to install a bunch of tools, so python -m pip.
1:16 Note, by the way, that when I type this, this Python over here is going to refer to the Python inside of my virtualenv.
1:22 It might just be good to show that as well. So if I call whichPython now, you can see that I'm now inside of this very special
1:31 spacey course virtual environment folder. And if I were to deactivate my virtual environment and call whichPython again,
1:37 you are going to see that I've got a different Python. With that said, go back to the virtual environment, bin, activate it, back inside.
1:46 And now I'm just going to go ahead and pip install something. I usually like to run python -m pip,
1:52 mainly because it's explicit this way that the Python that I'm using is the one from this virtual environment,
1:58 and it's not capturing some global pip or anything like that. But okay, pip install spacey. That's definitely a package that I want to have.
2:07 And in this case, I would also like to have JupyterLab around because that's a very easy environment to do some demos with.
2:13 So I'll go ahead and install those. Depending on your machine, this might have taken a minute,
2:19 but we can totally confirm now that a bunch of stuff got installed, which is great. For this series of videos, though, there's one
2:25 extra thing that we want to have, and that is that we also want to have a spacey model downloaded. You will see this in more detail in
2:34 upcoming videos, but in essence, spacey provides a bunch of pre-trained models for you that you can do natural language stuff with.
2:43 But that also means that you've got to download such a model up front. And in this series of videos, we're going to go ahead
2:49 and use the English Medium model. This is a model that's relatively good, but still relatively lightweight as well. It's about 42 megabytes.
2:58 Great. And with that now downloaded, we should have everything that we need to get started. So what I'm going to do now is just call
3:11 JupyterLab from this virtual environment that has spacey. And this will start up Jupyter. It'll also give me a link that I can open.
3:20 And when I click the link, I'm in this familiar JupyterLab interface, and I can open up a new notebook to get going.


Talk Python's Mastodon Michael Kennedy's Mastodon