为了测试爬虫程序,在运行过程中需要用到lxml,但是运行时出现了ModuleNotFoundError: No module named ‘lxml’ 的错误提示,本以为只需安装lxml即可,但是没想要,自己试着解决,有在网上查找,但是依然无法解决,安装lxml过程中始终出现下面的错误代码提示。
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building ‘lxml.etree’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
最后实在没有办法了,只能试着把高版本的python卸载了,安装低版本的试一试,没想到竟然安装得上去了。