好像是在python3.5之后,安装了lxml也无法使用etree
为了就解决这个问题使用如下方法:
1、下载lxml的wheel文件,下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
2、将下载的wheel文件放到路径下
3、pip安装wheel文件
pip install lxml-4.4.2-cp36-cp36m-win_amd64.whl
4、验证安装
cmd先进入python界面,再输入
from lxml import etree
无报错表示成功
PS.如果Pycharm 使用from lxml import etree 报了个错Unresolved reference 'etree',但是能运行...
解决方法:
其他提示unresolved reference应该也适用吧:
1、点击菜单栏上的File -> Setting ->Build,Executing,Development ->Console -> Python Console
2、将Add source roots to PYTHONPATH勾选上
3、点击Apply