Python:ImportError: lxml not found,请安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44954802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python: ImportError: lxml not found, please install it
提问by Jazz
I have the following code (in PyCharm (MacOS)):
我有以下代码(在 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)).
在 Anaconda 中确实出现安装了lxml
( 3.8.0
)的最新版本。尽管,我曾尝试重新安装它:1)写作pip install lxml
和2)下载lxml
对应于我的Python版本(轮lxml-3.8.0-cp36-cp36m-win_amd64.whl
),但在任何情况下都保持我得到相同的(在第二种情况下,它是not a supported wheel on this platform
,即使python的版本是正确的(3.6,64位))。
I've read similar questions here (even with the same code above, since it's from a tutorial), but the problem still persists.
我在这里读过类似的问题(即使使用上面相同的代码,因为它来自教程),但问题仍然存在。
回答by Willem Van Onsem
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.xis pip3
. So you probably should install it with:
这意味着您正在使用python-3.6。现在通常python-3.x的包管理器是pip3
. 所以你可能应该安装它:
pip3 install lxml
回答by Ruxi Zhang
I got same error, it seems that my python3 was pointing to pandas in python2 (since I have not install pandas in python3). After doing pip3 install pandas and restarting a notebook, it worked fine.
我遇到了同样的错误,似乎我的 python3 指向了 python2 中的熊猫(因为我没有在 python3 中安装熊猫)。在执行 pip3 install pandas 并重新启动笔记本后,它工作正常。
回答by Krish PG
You can go to Settings > Project Interpreter > Click on '+' icon
Find 'lxml' from the list of packages and click 'Install Package' button found below.
I am using PyCharm 2019.2.1 (Community Edition)
Build #PC-192.6262.63, built on August 22, 2019
Runtime version: 11.0.3+12-b304.39 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-58-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 937M
Cores: 4
您可以转到“设置”>“项目解释器”> 单击“+”图标
从包列表中查找“lxml”,然后单击下面的“安装包”按钮。
我正在使用 PyCharm 2019.2.1(社区版)
Build #PC-192.6262.63,构建于 2019 年 8 月 22 日
运行时版本:11.0.3+12-b304.39 amd64
VM:JetBrains sro
Linux 的OpenJDK 64 位服务器 VM 4.15.0-58-generic
GC:ParNew,ConcurrentMarkSweep
内存:937M
核心:4