【问题】

python脚本,其中用到Beautifulsoup:

from BeautifulSoup import BeautifulSoup,Tag,CData;

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

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

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

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

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

【解决过程】

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

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

去看到:

from bs4 import BeautifulSoup
 
soup = BeautifulSoup(open("index.html"))
 
soup = BeautifulSoup("data")

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

from BeautifulSoup import BeautifulSoup,Tag,CData;

改为:

from bs4 import BeautifulSoup,Tag,CData;

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

http://www.crifan.com/python3_after_install_bs4_still_error_importerror_no_module_named_beautifulsou