Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named BeautifulSoup

I have installed BeautifulSoup using easy_install and trying to run following script

from BeautifulSoup import BeautifulSoup import re  doc = ['<html><head><title>Page title</title></head>',        '<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',        '<p id="secondpara" align="blah">This is paragraph <b>two</b>.',        '</html>'] soup = BeautifulSoup(''.join(doc))  print soup.prettify() 

But not sure why this is happening

Traceback (most recent call last):   File "C:\Python27\reading and writing xml file from web1.py", line 49, in <module>     from BeautifulSoup import BeautifulSoup ImportError: No module named BeautifulSoup 

Could you please help. Thanks

like image 411
Muhammad Imran Avatar asked Apr 14 '11 13:04

Muhammad Imran


People also ask

How do I import from Beautifulsoup?

To use beautiful soup, you need to install it: $ pip install beautifulsoup4 . Beautiful Soup also relies on a parser, the default is lxml . You may already have it, but you should check (open IDLE and attempt to import lxml). If not, do: $ pip install lxml or $ apt-get install python-lxml .


1 Answers

Try this from bs4 import BeautifulSoup

This might be a problem with Beautiful Soup, version 4, and the beta days. I just read this from the homepage.

like image 168
James R. Clayton Avatar answered Sep 23 '22 13:09

James R. Clayton