2014-01-08 272 views
1

我正在嘗試將美麗的Soup4-4.1.0導入到Python 3.3中(我已經放入了美麗的湯:C:\Python33\Lib\site-packages\BeautifulSoup\bs4)。嘗試導入BeautifulSoup時出現異常

使用下列內容:

from BeautifulSoup import bs4 

我收到以下錯誤:

Traceback (most recent call last): 
    File "<pyshell#5>", line 1, in <module> 
    from BeautifulSoup import bs4 
    File "C:\Python33\lib\site-packages\BeautifulSoup\bs4\__init__.py", line 175 
    except Exception, e: 

任何人都可以在這方面幫助?

回答

1

我建議你閱讀BeautifulSoup documentation因爲我舉:

Beautiful Soup 4 works on both Python 2 (2.6+) and Python 3.

在任何情況下BeautifulSoup 4通過PyPI將公佈,因此,如果您不能與系統打包安裝它,您可以安裝它用easy_install或pip。包名是beautifulsoup4,及相同的封裝工作在Python 2和Python 3的

$ easy_install beautifulsoup4 

$ pip install beautifulsoup4 

如果你沒有的easy_install或PIP安裝,你可以下載BeautifulSoup 4源碼包,並通過setup.py安裝。 [轉到該文件夾​​並運行命令setup.py install(假設* .py在路徑擴展中是已知的,否則運行

c:\pythonXX\python setup.py install). 
+0

非常感謝! – Prairy

相關問題