mac下安裝python-lxml

當沒安裝lxml的時候,終端中運行python文件會報錯:

Traceback (most recent call last):

  File "web_parse.py", line 4, in <module>

    Soup = BeautifulSoup(wb_data,'lxml')

  File "/Library/Python/2.7/site-packages/bs4/__init__.py", line 152, in __init__

    % ",".join(features))

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?



打開終端

cd到相關的文件夾,

sudo easy_install lxml


Searching for lxml

Best match: lxml 3.8.0

Processing lxml-3.8.0-py2.7-macosx-10.11-intel.egg

lxml 3.8.0 is already the active version in easy-install.pth


Using /Library/Python/2.7/site-packages/lxml-3.8.0-py2.7-macosx-10.11-intel.egg

Processing dependencies for lxml

Finished processing dependencies for lxml



然後這就表示安裝完成了;


還可以在終端安裝beautifulsoup

同樣在相關文件夾中

sudo easy_install beautifulsoup4


Searching for beautifulsoup4

Best match: beautifulsoup4 4.3.2

beautifulsoup4 4.3.2 is already the active version in easy-install.pth


Using /Library/Python/2.7/site-packages

Processing dependencies for beautifulsoup4

Finished processing dependencies for beautifulsoup4



這就表示安裝完成了;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章