【问题标题】:ImportError: No module named bs4 using CanopyImportError:没有使用 Canopy 的名为 bs4 的模块
【发布时间】:2015-06-23 19:30:50
【问题描述】:

所以我对这些东西有点陌生,但我试图了解数据抓取。我在网上使用了一些名为“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

【问题讨论】:

  • 尝试通过 pip install --upgrade beautifulsoup4 升级它。如果不起作用,请卸载并重新安装它,看看效果如何。

标签: python python-2.7 beautifulsoup canopy bs4


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-07-31
    • 1970-01-01
    • 2014-10-31
    • 2017-06-18
    • 2015-01-02
    • 2016-02-27
    • 2017-02-19
    • 2018-12-30
    • 2021-04-02
    相关资源
    最近更新 更多