0

I'm running this code

import bs4 as bs
import urllib.request

sauce = urllib.request.urlopen('http://pythonprogramming.net/parsememcparseface')

soup = bs.BeautifulSoup(sauce, 'lxml')

print(soup)

and I'm getting this error

ModuleNotFoundError: No Module named 'bs4'

I've installed beautiful soup using

sudo pip install beautifulsoup4

and there were no errors.

I thought it might have installed bs4 to my python 2.7 library, but I can't find it there. I also can't find my python 3 library anywhere. Any ideas what I should do to get python 3 to recognize beautifulsoup?

Mdomin45
  • 469
  • 1
  • 6
  • 14
  • Possible duplicate of [selenium getting install under python 2.7 site packages](http://stackoverflow.com/questions/37108370/selenium-getting-install-under-python-2-7-site-packages) – e4c5 May 16 '17 at 07:34
  • "I also can't find my python 3 library anywhere" Sounds like you have some things to sort out. Also, show us whether this code was run in Python 2 or 3. – Arya McCarthy May 16 '17 at 07:34
  • 1
    In order to avoid this kind of issues in the future, use `virtualenv` – Jahongir Rahmonov May 16 '17 at 07:44

1 Answers1

1

My guess is that pip points to your python 2.7 installation, check pip version with pip --version

To make sure its installing to python 3, use pip3:

sudo pip3 install beautifulsoup4
Gaurav Paliwal
  • 1,556
  • 16
  • 27
Cleared
  • 2,490
  • 18
  • 35