添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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
                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, 2022 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, 2022 at 22:38
                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, 2022 at 0:20

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. – Community Feb 4, 2022 at 15:54

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.