3

I am using Homebrew to install python on Snow Leopard.

After installing python (2.7.2), I add /usr/local/share/python to the front of my PATH. I also set PYTHONPATH to /usr/local/lib/python2.7/site-packages.

If I use pip to install lxml or feedparser, for example, then after running python, I can import lxml with no issue.

After running pip install BeautifulSoup, there exists a .egg-info directory for BeautifulSoup in the site-packages directory listed above, as well as the bs4 directory, but from BeautifulSoup import BeautifulSoup just gives me an error in the python interpreter.

sys.path is:

['', 
 '/usr/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg', 
 '/Users/Chris/src/python-pinboard', 
 '/usr/local/lib/python2.7/site-packages', 
 '/usr/local/Cellar/python/2.7.2/lib/python27.zip', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-darwin', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-mac', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-mac/lib-scriptpackages', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/lib-tk', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/lib-old', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/lib-dynload', 
 '/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages']

Any idea what's going on?

Update: Solution Found

By default, latest BeautifulSoup, 4.0b, gets installed. Use stable release, pip install BeautifulSoup==3.2.0, and importing etc. works.

2

By default, latest BeautifulSoup, 4.0b, gets installed. Use stable release, pip install BeautifulSoup==3.2.0, and importing etc. works.

0

BeautifulSoup is now splitted into beautifulsoup (version 3..) and beautifulsoup4 (version 4..) in pip.

So to install a specific version run:

sudo pip install beautifulsoup # version 3

or

sudo pip install beautifulsoup4 # version 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.