我在我的ubuntu 10.04上运行python 3.1.2
我需要安装哪个版本的BeautifulSoup以及如何安装?
我已经下载了3.2版并运行了sudo python3 setup.py install,但不能正常工作
thnx
编辑:我得到的错误是:
>>> import BeautifulSoup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "BeautifulSoup.py", line 448
raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
^
SyntaxError: invalid syntax
>>> 发布于 2011-02-19 22:52:51
发布于 2012-10-26 00:44:10
我按照以下步骤安装了用于超文本标记语言解析的beautifulsoup4。
$ python3 setup.py安装
$ import bs4 $ from bs4 import BeautifulSoup
第一条语句可以工作,而第二条语句将失败。您必须使用此命令将BeautifulSoup模块转换为python3格式。
$ 2to3 -w bs43之后,您可以再次运行测试,一切都将正常工作。
发布于 2012-09-02 02:03:58
https://stackoverflow.com/questions/5050596
复制相似问题