beautifulsoup won't recognize lxml

后端 未结 2 1369
眼角桃花
眼角桃花 2020-12-16 15:05

I\'m attempting to use lxml as the parser for BeautifulSoup because the default one is MUCH slower, however i\'m getting this error:

    soup =          


        
相关标签:
2条回答
  • 2020-12-16 15:34

    Go to these pages:

    1. https://pypi.python.org/pypi/cssselect

    2. https://pypi.python.org/pypi/lxml/3.2.5

    download the source files for both packages. Expand each of them into a different folder. Then in each folder locate the setup.py file and run the following command:

    python setup.py install
    

    You may run into some problems with lxml. If you get an error like

    error: command 'gcc' failed with exit status 1
    

    make sure you install libxml2-dev & libxslt1-dev using

    sudo apt-get install libxml2-dev libxslt1-dev
    

    Hopefully that should work.

    0 讨论(0)
  • 2020-12-16 15:40

    It looks like lxml has not been successfully installed. To install lxml on Ubuntu, run

    sudo apt-get install libxslt1-dev libxml2
    

    In virtualenv:

    pip install --upgrade lxml
    pip install cssselect
    
    0 讨论(0)
提交回复
热议问题