Python ImportError: No module named BeautifulSoup

【问题】

python脚本,其中用到Beautifulsoup:

<br />
from BeautifulSoup import BeautifulSoup,Tag,CData;<br />

为了支持Python 3,所以去主页:

http://www.crummy.com/software/BeautifulSoup/

下载了beautifulsoup4-4.1.3.tar.gz,并安装了Beautifulsoup 4。

然后去运行python脚本,结果却还是出错:

<br />
Traceback (most recent call last):<br />
  File "G:\34563264_data_from_site\34563264_data_from_site.py", line 38, in<br />
    from BeautifulSoup import BeautifulSoup,Tag,CData;<br />
ImportError: No module named BeautifulSoup<br />

【解决过程】

1.后来是参考bs4的官网文档:

http://www.crummy.com/software/BeautifulSoup/bs4/doc/

去看到:

<br />
from bs4 import BeautifulSoup</p>
<p>soup = BeautifulSoup(open("index.html"))</p>
<p>soup = BeautifulSoup("data")<br />

然后才知道,原来Beautifulsoup 4,改名为bs4了,所以把:

<br />
from BeautifulSoup import BeautifulSoup,Tag,CData;<br />

改为:
<br />
from bs4 import BeautifulSoup,Tag,CData;<br />

然后就可以消除此错误,可以正常使用Beautifulsoup了。

http://www.crifan.com/python3_after_install_bs4_still_error_importerror_no_module_named_beautifulsou

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.