Setting Up Your Web Scraping Environment
00:00 I’ll just be working in a terminal, but feel free to use any sort of code editor that you want. I’m working on macOS, so if you’re on Windows, your commands in the terminal might look a little bit differently.
00:12
I’m going to navigate into the documents folder and into the Real Python folder and then here I’m going to start off by creating a virtual environment. For this, I’ll say python -m venv, calling the venv module.
00:26
And then I will call my virtual environment venv in this case.
00:32
Next, I need to activate it. On macOS I can do that by sourcing the activate script. So I will say source venv/bin/activate, and that activates my virtual environment.
00:45
If you are on Windows, this command is going to be a bit different. You won’t need to call source and instead of the bin folder, you’ll have to go to Scripts.
00:54 Check out our virtual environments resource if you’re unfamiliar with these. Alright, I’ve activated the virtual environment and now I will install the Beautiful Soup library.
01:05
To do this, I can write the command, python -m pip install, and then beautifulsoup4. Press Enter. And it’s installed very quickly.
01:20
Now I’m just going to test that I have access to the library by going into the Python interpreter, and then I’m going to try to import bs4.
01:31 And since I’m not getting an error here, that means I successfully installed Beautiful Soup 4 into this virtual environment, which means that now I can work with it.
01:41 Alright, that’s all for setup.
01:46 In the next lesson, let’s create a Beautiful Soup object and take a peek at what it contains.
Become a Member to join the conversation.
