0

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
Sbk3824
  • 1,229
  • 1
  • 14
  • 24
  • Check shebang: `head -1 $(which gcovr)` — does it point to the Python in the virtualenv? – phd Jan 14 '22 at 18:07
  • Yes, it points to the Python in virtualenv `(env)[temp_sbk]$ head -1 $(which gcovr) #!/home/ec2-user/workspace/unit-test-coverage-test-2/temp_sbk/env/bin/python` – Sbk3824 Jan 14 '22 at 21:45
  • I try installing lxml `pip install lxml` and see the msg **Successfully installed lxml-4.7.1** , but `pip show lxml` returns **WARNING: Package(s) not found: lxml** – Sbk3824 Jan 14 '22 at 22:38
  • Rather strange. Puzzled… – phd Jan 14 '22 at 23:47
  • You're using Python 2.7 and gcovr 4.2, both of which are no longer supported. Please use a Python 3 version (3.6 or higher) and install gcovr 5.0. However, that isn't the cause of the error you're seeing. It seems you somehow installed gcovr and the dependencies in different virtualenvs?? Looking at the directories in Python's `sys.path` variable might help. – amon Jan 14 '22 at 23:55
  • 1
    more likely that `which pip` is not giving the pip for the version of Python you're trying to use. Try instead `python -m pip`, which should resolve inside the virtualenv. – Adam Smith Jan 15 '22 at 00:20

1 Answers1

0

After my one night thought, i have successfully fix it on this morning : Although you have install it on your pc but maybe you have the wrong path.

1.Go to D:(Your Project Folder)\venv\Lib\site-packages to find if there have folders named "lxml" and "lxml-(version).dist-info".

2.And then copy them to the location: D:(Your Project Folder)\Lib\site-packages

Hope this will help you !

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 04 '22 at 15:54