不懂就要问:pyenv 设置 py 版本,然后 pip 安装 BeautifulSoup4 不认 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
dibis
V2EX    Python

不懂就要问:pyenv 设置 py 版本,然后 pip 安装 BeautifulSoup4 不认

  •  
  •   dibis 2018-11-25 00:37:07 +08:00 2916 次点击
    这是一个创建于 2571 天前的主题,其中的信息可能已经有所发展或是发生改变。
    (v365env) music163-spiders git:(master) python get_artists.py Traceback (most recent call last): File "get_artists.py", line 44, in <module> get_artists(url) File "get_artists.py", line 26, in get_artists soup = BeautifulSoup(r.text, 'html5lib') File "/Users/qk/.pyenv/versions/v365env/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library? (v365env) music163-spiders git:(master) python --version Python 3.6.5 (v365env) music163-spiders git:(master) pip install requests BeautifulSoup4 Requirement already satisfied: requests in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (2.20.1) Requirement already satisfied: BeautifulSoup4 in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (4.6.3) Requirement already satisfied: idna<2.8,>=2.5 in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (from requests) (2.7) Requirement already satisfied: certifi>=2017.4.17 in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (from requests) (2018.10.15) Requirement already satisfied: urllib3<1.25,>=1.21.1 in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (from requests) (1.24.1) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/qk/.pyenv/versions/3.6.5/envs/v365env/lib/python3.6/site-packages (from requests) (3.0.4) (v365env) music163-spiders git:(master) python get_artists.py Traceback (most recent call last): File "get_artists.py", line 44, in <module> get_artists(url) File "get_artists.py", line 26, in get_artists soup = BeautifulSoup(r.text, 'html5lib') File "/Users/qk/.pyenv/versions/v365env/lib/python3.6/site-packages/bs4/__init__.py", line 198, in __init__ % ",".join(features)) bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library? 

    参考例子:

    https://github.com/zyingzhou/music163-spiders

    5 条回复    2018-11-25 10:19:15 +08:00
    dibis
        1
    dibis  
    OP
       2018-11-25 00:41:41 +08:00
    '''
    ~ pyenv versions
    * system (set by /Users/qk/.pyenv/version)
    3.6.5
    3.6.5/envs/v365env
    v365env
    '''
    likuku
        2
    likuku  
       2018-11-25 00:52:39 +08:00
    @jnuc093

    ~ pyenv versions
    * system (set by /Users/qk/.pyenv/version)

    # 你这显示的表示你当前所在位置用的还是系统自带的 python 啊,并没有用到你 pyenv 安装的版本。
    likuku
        3
    likuku  
       2018-11-25 00:56:11 +08:00
    " Couldn't find a tree builder with the features you requested: html5lib"

    这么明确的提示了吗... 缺啥就装啥啊。

    确认你在你项目的目录下,确认使用你正确的 pyenv 或者 virtualenv 环境,

    pip search html5lib # 先确认 pip 库里有没有,我确认过了,有的。

    pip install html5lib # 装完它之后,再试吧
    quinoa42
        4
    quinoa42  
       2018-11-25 07:08:03 +08:00
    html5lib 并不是 beautifulsoap 的硬性依赖,要用的话得 pip install html5lib
    dibis
        5
    dibis  
    OP
       2018-11-25 10:19:15 +08:00
    (v365env) music163-spiders git:(master) pip install html5lib
    Collecting html5lib
    Using cached https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl
    Collecting six>=1.9 (from html5lib)
    Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
    Collecting webencodings (from html5lib)
    Using cached https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
    Installing collected packages: six, webencodings, html5lib
    Successfully installed html5lib-1.0.1 six-1.11.0 webencodings-0.5.1


    (v365env) music163-spiders git:(master) pyenv versions
    system
    3.6.5
    3.6.5/envs/v365env
    * v365env (set by PYENV_VERSION environment variable)
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3263 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 00:03 PVG 08:03 LAX 16:03 JFK 19:03
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86