MisterPi
MisterPi

Reputation: 1671

ImportError: No module named bs4?

I try to import library: from bs4 import BeautifulSoup.

When I run script I get error:

Traceback (most recent call last):
  File "index.py", line 9, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named bs4
root@srvr [/home/public_html/grabber/similar]# 

When I try install:

pip install beautifulsoup4

I get the following error:

Requirement already satisfied: beautifulsoup4 in /usr/lib/python2.6/site-packages/beautifulsoup4-4.5.1-py2.6.egg

Script is:

import sys
sys.path.append('/usr/lib/python2.6/site-packages')
from bs4 import BeautifulSoup

Upvotes: 2

Views: 23894

Answers (3)

Ilker Burak
Ilker Burak

Reputation: 121

If you use Pycharm, go to preferences - project interpreter - install bs4. If you try to install BeautifulSoup, it will still show that no module named bs4.

Upvotes: 0

Adrian Onu
Adrian Onu

Reputation: 671

If you try this on Mac OS X do the following:

  1. Go to the official website: http://www.crummy.com/software/BeautifulSoup/
  2. Download the .tar.gz package
  3. Unpack it
  4. Go to the unpacked folder
  5. Type: python setup.py install

Upvotes: 4

tobias_k
tobias_k

Reputation: 82939

You installed BeautifulSoup for Python 2.6, but according to your tag, you are using Python 3.x. To install explicitly for Python 3, use pip3 instead of pip, i.e.

pip3 install beautifulsoup4

Upvotes: 10

Related Questions