mac 上默认的pip install lxml 安装的是在 python2.7 版本下,python3 找不到lxml

来源:2-4 xpath实战

野生前端菜鸟

2018-07-03

python3 上运行 user_xpath_demo.py

from lxml import html
ModuleNotFoundError: No module named 'lxml'

pip 安装 lxml

sudo pip install lxml
Password:
The directory '/Users/wangxiaoyu/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/wangxiaoyu/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: lxml in /Library/Python/2.7/site-packages (4.2.3)
prompt-toolkit 1.0.15 has requirement six>=1.9.0, but you'll have six 1.4.1 which is incompatible.


写回答

1回答

NavCat

2018-07-03

你安装了python3 吗?使用pip3 install lxml试试

1
1
野生前端菜鸟
非常感谢!
2018-07-07
共1条回复

手把手教你把Python应用到实际开发 不再空谈语法

学会项目开发思路,掌握Python高阶用法。

1341 学习 · 244 问题

查看课程