您的位置:首页 > 编程语言 > Python开发

mac下安装python-lxml

2017-07-02 23:29 323 查看
当没安装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



这就表示安装完成了;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python mac 终端 lxml