BeautifulSoup in Python (with Windows 7)

Posted by

I wanted to parse some HTML, to better scrape data from the web, so I downloaded BeautifulSoup.

Unzipping was a snap, however I was initially unable to call it from the python shell. As googling this problem proved very frustrating, I figured posting my solution may be valuable to someone.

So …

If the command:

from BeautifulSoup import BeautifulSoup

yields:

Traceback (most recent call last):
File “”, line 1, in
from BeautifulSoup import BeautifulSoup
ImportError: No module named BeautifulSoup

You need to do the following:

1/ go to your BeautifulSoup folder, and run the setup file. This ought to create a file BeautifulSoup.pyc

2/ copy this file, and paste it into the following directory:

python27\Lib\site-packages\

3/ now type:

from BeautifulSoup import BeautifulSoup

into the python shell. If you observe a pause (loading) and then a new line:

>>>

you’re fixed! (I wish I’d found a post like this two hours ago …)

Advertisements

16 comments

  1. So I extract the file, run the setup file (double click on setup.py), but I do not see the BeautifulSoup.pyc file created.

  2. im having the same issue as the last post, running “python setup.py install” does not generate a beautifupsoup.pyc file

    1. I moved to a mac a year or so ago. I will dig out my old HP and have a look. I suggst you install easy install – it works with a bit of fiddling in windows.

  3. Yeah, same for me. beautifulsoup.pyc file. Just an egg file. And ez_setup doesn’t work, because it doesn’t work for 64-bit machines. I’m starting to think I need to install a virtual machine just for beautiful soup. Not so beautiful.

  4. this post gets lots of hits – it seems that there has been some change (perhaps at the BS end) that make this a little more tricky. I’m going to have a look at this when i get a chance to set up my old HP, but i never seem to find the time (i moved to a Mac, and you should too!).

    Until then, i suggest that you install via one of the package installer helpers. This Stackoverflow post seems to have the right stuff for getting it to work in Windows.

  5. Wow! I’m genuinely enjoying the style and design of your weblog. Are you using a customized theme or is this readily available to all users? If you do not want to say the name of it out in the public, please contact me. I’d absolutely love to get
    my hands on this template! Kudos.

  6. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set up? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% certain.
    Any suggestions or advice would be greatly appreciated.
    Many thanks

Comments are closed.