I have the following code (in PyCharm (MacOS)):
import pandas as pd fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states') print(fiddy_states)
And I get the following error:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/user_name/PycharmProjects/PandasTest/Doc3.py Traceback (most recent call last): File "/Users/user_name/PycharmProjects/PandasTest/Doc3.py", line 9, in <module> fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states') File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/html.py", line 906, in read_html keep_default_na=keep_default_na) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/html.py", line 733, in _parse parser = _parser_dispatch(flav) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/html.py", line 693, in _parser_dispatch raise ImportError("lxml not found, please install it") ImportError: lxml not found, please install it
In Anaconda does appear installed the last version of lxml
(3.8.0
). Despite of that, I have tried to reinstall it by: 1) writing pip install lxml
and 2) downloading the lxml
wheel corresponding to my python version (lxml-3.8.0-cp36-cp36m-win_amd64.whl
), but in any case all remains the same (in the second case I get that it is not a supported wheel on this platform
, even though the version of python is correct (3.6, 64 bits)).
I've read similar questions here (even with the same code above, since it's from a tutorial), but the problem still persists.
Open your Linux terminal or shell. Type “ pip install lxml ” (without quotes), hit Enter. If it doesn't work, try "pip3 install lxml" or “ python -m pip install lxml “. Wait for the installation to terminate successfully.
lxml is a Python library which allows for easy handling of XML and HTML files, and can also be used for web scraping. There are a lot of off-the-shelf XML parsers out there, but for better results, developers sometimes prefer to write their own XML and HTML parsers.
Based on the fact that the error is:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
This means that you are working with python-3.6. Now usually the package manager for python-3.x is pip3
. So you probably should install it with:
pip3 install lxml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With