How do I install a beautiful python soup on my mac? see error

I am running Mac OS X 10.7.3 on a Macbook Pro. It comes with Python 2.7.1 installed. I need a beautiful library of soups. So I did the following:

1) went to crummy.com and downloaded beautifulsoup4-4.0.2.tar.gz

2) uncompressed it

3) moved to an uncompressed directory and typed the following

python setup.py install

but I got an error that I could not write to any directory.

4), so I ran:

sudo python setup.py install

No mistakes! Okay right? Not really. When I try to run the program with the following:

from BeautifulSoup import *

I get the following error:

ImportError: No module named BeautifulSoup

What have I done wrong?

Thank!

+5
source share
2 answers

For BeautifulSoup4 you should use

from bs4 import BeautifulSoup

Check Document: BS4 Document

+12

, pip easy_install? , :

$ easy_install BeautifulSoup

, pip ( , easy_install pip):

$ pip install BeautifulSoup

, . , python, , , , ? python --version - , :

import sys
print sys.version  # => '2.7.2 (default, Feb  4 2012, 02:01:30)...
+4

All Articles