我有下面的代碼(在PyCharm(MacOS的)):的Python:導入錯誤:LXML不存在,請安裝
import pandas as pd
fiddy_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
print(fiddy_states)
而且我得到以下錯誤:
/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
在蟒蛇確實出現安裝lxml
(3.8.0
)的最新版本。儘管,我曾嘗試重新安裝它:1)寫作pip install lxml
和2)下載對應於我的Python版本(lxml-3.8.0-cp36-cp36m-win_amd64.whl
)的lxml
輪,但在任何情況下都保持不變(在第二種情況下我得到它是not a supported wheel on this platform
,即使python的版本是正確的(3.6,64位))。
我在這裏讀過類似的問題(即使使用上面相同的代碼,因爲它來自教程),但問題仍然存在。
那麼'pip3 install lxml'呢? –