ImportError: No module named bs4 using Canopy

1.5k views Asked by At

So I'm kinda new to this stuff but I was trying to learn about data scraping. I was using some doc file online called "A beginner’s guide to data scraping in Python" and this was the code it told me to run:

import urllib2
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://www.bcsfootball.org').read())
for row in soup('table', {'class': 'mod-data'})[0].tbody('tr'):
    tds = row('td')
    print tds[0].string,tds[1].string

But when I ran it. I got

ImportError: No module named bs4 

I went around online and I tried installing BeautifulSoup4 using stuff like

Command Prompt:

easy_install BeautifulSoup4

And installing get-pip.py and running:

pip install BeautifulSoup4

(I used this after I tried the easy_install and it said something like requirement already satisfied so I'm guessing it was installed??)

Please help :(

Oh, Uhm I'm also using python 2.7.10

1

There are 1 answers

0
Jonathan March On BEST ANSWER

Sounds like you are not installing the package into Canopy Python but rather into your system (or other) python. See https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line