2

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?

enter image description here

beautiful soup directory

quantum
3,8881 gold badge32 silver badges51 bronze badges
asked Oct 21, 2012 at 17:16
1
  • Open terminal, start python and type this: help('modules'). Do you see anything related to BeautifulSoup there? Commented Oct 21, 2012 at 17:19

3 Answers 3

5

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.

answered Oct 21, 2012 at 17:25
Sign up to request clarification or add additional context in comments.

Comments

2

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
answered Oct 21, 2012 at 17:27

Comments

2

To use BeautifulSoup 4, you need to:

from bs4 import BeautifulSoup

It seems to me like you are reading the wrong manual.

answered Oct 21, 2012 at 17:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.