Litmon
Litmon

Reputation: 267

Missing parser library (lxml) in Anaconda with Python

I've installed Anaconda and the modules for requests, bs4, lxml, selenium through pip.

When I do this:

from bs4 import BeautifulSoup
soup = BeautifulSoup(txt, 'lxml')

I get the error:

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. 

Do you need to install a parser library?

I found a number of questions on this already, and here's what I've tried (but none have worked):

  1. Uninstall/reinstall lxml
  2. Download the whl file for lxml and load it manually (when I did this, it said that lxml was already satisfied)
  3. conda install -x auto htmlparser (I got the error - packagesnotfounderror: the following packages are not available from current channels)
  4. I've checked that my bs4 and lxml are fully upgraded

I'm not a programmer, so please keep that in mind in your responses, this is my first foray into the programming world. Thank you!

Upvotes: 3

Views: 6303

Answers (1)

Tomer Amit
Tomer Amit

Reputation: 21

I had the same problem, able to solve it by uninstalling lxml from conda and install it with pip.

those are my packages when installing all with conda

Name                    Version                   Build  Channel
asn1crypto                0.24.0                   py37_0
beautifulsoup4            4.7.1                    py37_1
ca-certificates           2019.1.23                     0
certifi                   2018.11.29               py37_0
cffi                      1.11.5           py37h74b6da3_1
chardet                   3.0.4                    py37_1
cryptography              2.5              py37h7a1dbc1_0
idna                      2.8                      py37_0
libiconv                  1.15                 h1df5818_7
libxml2                   2.9.9                h464c3ec_0
libxslt                   1.1.33               h579f668_0
lxml                      4.3.1            py37h1350720_0
openssl                   1.1.1a               he774522_0
pip                       19.0.1                   py37_0
pycparser                 2.19                     py37_0
pyopenssl                 19.0.0                   py37_0
pysocks                   1.6.8                    py37_0
python                    3.7.2                h8c8aaf0_2
requests                  2.21.0                   py37_0
selenium                  3.141.0          py37he774522_0
setuptools                40.8.0                   py37_0
six                       1.12.0                   py37_0
soupsieve                 1.7.1                    py37_0
sqlite                    3.26.0               he774522_0
urllib3                   1.24.1                   py37_0
vc                        14.1                 h21ff451_3    anaconda
vs2015_runtime            15.5.2                        3    anaconda
wheel                     0.32.3                   py37_0
win_inet_pton             1.0.1                    py37_1
wincertstore              0.2                      py37_0
zlib                      1.2.11               h62dcd97_3

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

after uninstalling via conda and install via pip

Name                    Version                   Build  Channel
asn1crypto                0.24.0                   py37_0
beautifulsoup4            4.7.1                    py37_1
ca-certificates           2019.1.23                     0
certifi                   2018.11.29               py37_0
cffi                      1.11.5           py37h74b6da3_1
chardet                   3.0.4                    py37_1
cryptography              2.5              py37h7a1dbc1_0
idna                      2.8                      py37_0
libiconv                  1.15                 h1df5818_7
libxml2                   2.9.9                h464c3ec_0
libxslt                   1.1.33               h579f668_0
lxml                      4.3.1                     <pip>
openssl                   1.1.1a               he774522_0
pip                       19.0.1                   py37_0
pycparser                 2.19                     py37_0
pyopenssl                 19.0.0                   py37_0
pysocks                   1.6.8                    py37_0
python                    3.7.2                h8c8aaf0_2
requests                  2.21.0                   py37_0
selenium                  3.141.0          py37he774522_0
setuptools                40.8.0                   py37_0
six                       1.12.0                   py37_0
soupsieve                 1.7.1                    py37_0
sqlite                    3.26.0               he774522_0
urllib3                   1.24.1                   py37_0
vc                        14.1                 h21ff451_3    anaconda
vs2015_runtime            15.5.2                        3    anaconda
wheel                     0.32.3                   py37_0
win_inet_pton             1.0.1                    py37_1
wincertstore              0.2                      py37_0
zlib                      1.2.11               h62dcd97_3

Collecting lxml Using cached https://files.pythonhosted.org/packages/12/9e/316022255a2b715b0efaa967aa89119544906b3ed4f5131c1c9b6962baca/lxml-4.3.1-cp37-cp37m-win_amd64.whl Installing collected packages: lxml Successfully installed lxml-4.3.1

works for me :)

Upvotes: 2

Related Questions