我正在尝试在 virtualenv 中安装 gcovr 工具并且工具安装良好,但是在运行二进制文件时,我看到 lxml 警告,我该如何解决这个问题?
使用的命令:
pip install virtualenv
virtualenv env
source env/bin/activate
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
sudo yum -y install libxslt-devel libxml2-devel
which gcovr
pip install gcovr
gcovr --help
我看到以下错误(添加部分日志):
20:40:03 + which gcovr
20:40:03 /home/ec2-user/workspace/unit-test-coverage-test-2/temp_sbk/env/bin/gcovr
20:40:03 + pip install gcovr
20:40:03 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
20:40:03 Requirement already satisfied: gcovr in ./env/lib/python2.7/dist-packages (4.2)
20:40:04 Collecting lxml
20:40:04 Using cached lxml-4.7.1-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (5.5 MB)
20:40:04 Requirement already satisfied: jinja2 in ./env/lib/python2.7/dist-packages (from gcovr) (2.11.3)
20:40:04 Collecting MarkupSafe>=0.23
20:40:04 Using cached MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl (24 kB)
20:40:04 Installing collected packages: lxml, MarkupSafe
20:40:04 Successfully installed MarkupSafe-1.1.1 lxml-4.7.1
20:40:04 + gcovr --help
20:40:04 Traceback (most recent call last):
20:40:04 File "/home/ec2-user/workspace/unit-test-coverage-test-2/temp_sbk/env/bin/gcovr", line 5, in <module>
20:40:04 from gcovr.__main__ import main
20:40:04 File "/home/ec2-user/workspace/unit-test-coverage-test-2/temp_sbk/env/local/lib/python2.7/dist-packages/gcovr/__main__.py", line 54, in <module>
20:40:04 from .cobertura_xml_generator import print_xml_report
20:40:04 File "/home/ec2-user/workspace/unit-test-coverage-test-2/temp_sbk/env/local/lib/python2.7/dist-packages/gcovr/cobertura_xml_generator.py", line 11, in <module>
20:40:04 from lxml import etree
20:40:04 ImportError: No module named lxml
编辑1:
我尝试安装 lxml,看起来 lxml 已经安装但没有出现在 virtualenv 中
(env) [temp_sbk]$ pip install lxml
Collecting lxml
Using cached lxml-4.7.1-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (5.5 MB)
Installing collected packages: lxml
Successfully installed lxml-4.7.1
(env) [temp_sbk]$ pip show lxml
WARNING: Package(s) not found: lxml