1

所以我对这些东西有点陌生,但我试图了解数据抓取。我在网上使用了一些名为“Python 数据抓取初学者指南”的文档文件,这是它告诉我运行的代码:

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

但是当我运行它时。我有

ImportError: No module named bs4 

我在网上四处走动,我尝试使用类似的东西安装 BeautifulSoup4

命令提示符:

easy_install BeautifulSoup4

并安装 get-pip.py 并运行:

pip install BeautifulSoup4

(我在尝试了 easy_install 后使用了它,它说要求已经满足,所以我猜它已经安装了??)

请帮忙 :(

哦,嗯,​​我也在使用 python 2.7.10

4

1 回答 1

0

听起来您没有将软件包安装到 Canopy Python 中,而是安装到您的系统(或其他)python 中。请参阅https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line

于 2015-06-23T20:16:10.980 回答