from bs4 import BeautifulSoup error

11,157 views
Skip to first unread message

袁浦豪

unread,
Jun 15, 2013, 3:20:18 AM6/15/13
to beauti...@googlegroups.com
I try to install beautifulsoup4 om my mac pro. My os is OS X 10.8.3.I even try wiht python 2.7.2, 2.7.3
I think I have sucessfully install the bs4, but when I use it, something error happened.
I use <code>sudo pip install beautifulsoup4</code>. All is well.
So I write a simple python program with the code <code>from bs4 import BeautifulSoup</code>

cannot import name BeautifulSoup

If I change it to 
from bs4 import *
soup = BeautifulSoup(html_doc)

Error:name 'BeautifulSoup' is not defined

I'm confused!

If someone can tell me what's wrong with it?

Pepsodent Cola

unread,
Jul 3, 2013, 7:56:22 PM7/3/13
to beauti...@googlegroups.com
1.)
Linux@PC ~ $ pip freeze | grep -i "soup"

Warning: cannot find svn location for distribute==0.6.28dev-r0
BeautifulSoup==3.2.1


2.)
from bs4 import BeautifulSoup


3.)
According to Bengt...

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

Pepsodent Cola

unread,
Jul 3, 2013, 8:13:08 PM7/3/13
to beauti...@googlegroups.com
Ignore point 2.) I suspect I'm using both a pip installed Soup3 and a manually compiled Soup4.  I have no idea which I'm using exactly right now. :)
I'm still a newbie.

Mansi Mehta

unread,
Aug 1, 2017, 7:22:19 AM8/1/17
to beautifulsoup
Still cannot import bs4 after installing this on my windows10 PC ?

animes...@skymaptech.com

unread,
Aug 1, 2017, 9:13:00 AM8/1/17
to beautifulsoup

Do "pip install bs4"
also check for in which version of python you are installing 

For precise intstallation use "python2.7 -m pip install bs4"
change python version as required

Mansi Mehta

unread,
Aug 20, 2017, 8:35:54 AM8/20/17
to beautifulsoup
By this command "from bs4 import BeautifulSoup" shows this error ?

Error:
bs4\_init.py
bs4\builder\_init.py
bs4\builder\_html5lib.py
AttributeError: 'module' object has no attribute '_base'

Jane Pham

unread,
Aug 31, 2017, 7:32:06 AM8/31/17
to beautifulsoup
I have the somewhat similar problem but on window. I could not run "from bs4 import beautifulsoup".
the error message is that there is no bs4.

I manually install beautifulsoup4 by downloading the zip package and put in library/site-package. because i could not use pip or easy_install due to proxy awareness problem.

so go into bs4 file and run one file at a time and two file gave me the error that 
.builder element module could not be found

does anyknow how do i check if i have properly install beautifulsoup4 in my site-packages?

Best,
Jane

Marx babu

unread,
Nov 24, 2017, 7:19:49 AM11/24/17
to beautifulsoup
Recently i faced the same problem and this worked for me ;Please try :

Copied from one of the web reference :

I had the same issue after installing beautifulsoup4_4.5.1 on Python 3.4 via copying the .tar file. What worked for me was uninstalling the beautifulsoup and installing it again using the pip install method. If installation is successful, you will find bs4 in the list of installed modules. Here are the steps:

  1. c:\Python34\Scripts\pip.exe uninstall beautifulsoup4

  2. c:\Python34\Scripts\pip.exe install beautifulsoup4

  3. c:\Python34\python.exe

  4. help('modules')

  5. from bs4 import BeautifulSoup


Best 
Marx mbmarx
Reply all
Reply to author
Forward
0 new messages