简体   繁体   中英

ImportError: No module named lxml , although lxml is installed

I'm trying to install gcovr tool in virtualenv and tools installs well, but on running the binary, i see warnings with lxml, how do i fix this?

Commands used:

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

I see following error(adding some part of logs):

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

Edit 1:

I try installing lxml, looks like lxml is already installed but isn't showing up in 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

maybe this: WARNING: The candidate selected for download or install is a yanked version: 'lxml' candidate (version 4.7.0 at https://files.pythonhosted.org/packages/6d/2d/6 f015083e400557990c5a5182d27c629eb8203eca10e8e92dc8e67ac8ea9/lxml-4.7.0-cp310-cp310-win_amd64.whl#sha256=4bbefbcedb29c7da21919c4768415be87d07d5715d571f190829fa39b76952bf (from https://pypi.org/simple/lxml/ ) (requires-python:>=2.7, .=3.0. , .=3.1. , .=3.2. , .=3.3. , .= 3.4:*)) Reason for being yanked. The binary wheels of lxml 4.7.0 were missing files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM