Reputation: 21302
I'm following a tutorial on creating a map using Python and the Beautiful Soup library.
I have downloaded beautiful soup and the folder is called "beautifulsoup4-4.1.3". The contents of this folder are in the attached image.
During the tutorial I am given the following code to use to import my data and beautiful soup:
import csv
from BeautifulSoup import BeautifulSoup
Trouble is that there is no file called "beautiful soup" within the beautiful soup folder. I have also attached the error message I receive in the terminal.
How should I import beautiful soup when there is no file with that name? I tried simply changing the folders name to "beautiful soup". I did not expect that to work and I was right - it did not.
Any advice on how to proceed welcome?
Upvotes: 2
Views: 980
Reputation: 1124558
You installed the BeautifulSoup library version 4, which has been renamed:
from bs4 import BeautifulSoup
If you want the old name and matching API, you need to install BeautifulSoup 3 instead:
easy_install BeautifulSoup
Note that since your tutorial is using from BeautifulSoup import BeautifulSoup
it may not entirely work with the updated API of BeautifulSoup version 4. If you run into problems, take a look at the porting to BS4 section of the BeautifulSoup documentation to 'translate' BS 3 code to the 4 API.
Upvotes: 5
Reputation: 53561
Either move the bs4
folder in the same directory as your script, or install the module via easy_install
or pip
. Then you can import it like this:
from bs4 import BeautifulSoup
Upvotes: 2
Reputation: 3840
To use BeautifulSoup 4, you need to:
from bs4 import BeautifulSoup
It seems to me like you are reading the wrong manual.
Upvotes: 2