eriwen / lcov-to-cobertura-xml

Converts lcov output to Cobertura-compatible XML for CI
https://eriwen.github.io/lcov-to-cobertura-xml/
Apache License 2.0
187 stars 73 forks source link

Cannot import name 'LcovCobertura' from 'lcov_cobertura' (unknown location) #41

Closed jschwe closed 2 years ago

jschwe commented 2 years ago

Hi,

With the new version 2 release I am getting the following ImportError:

  File "/home/jschwender/xxx/CI/scripts/./convert_lcov_to_cobertura.py", line 5, in <module>
    from lcov_cobertura import LcovCobertura
ImportError: cannot import name 'LcovCobertura' from 'lcov_cobertura' (unknown location)

I'm using python3.9. After downgrading back to version 1.6 the import works again. Any changes I should be aware of? The Readme still recommends to use from lcov_cobertura import LcovCobertura, is this wrong now?

cgutierr-zgz commented 2 years ago

Same thing here

sonofsky2010 commented 2 years ago

I try bellow code, it works.

from lcov_cobertura import lcov_cobertura
lcov_cobertura. LcovCobertura
cgutierr-zgz commented 2 years ago

If I install lcov_cobertura==1.6 it does work fine like that, otherwise it doesn't @sonofsky2010

oliviermartin commented 2 years ago

After having the issue, I have investigated what is going on.

The issue comes the use of setup.cfg - before using this file, setup.py was looking like that: https://github.com/eriwen/lcov-to-cobertura-xml/blob/1.6/setup.py ... particularly there were these two lines in setup.py:

sys.path.append('lcov_cobertura')
import lcov_cobertura

setup.py was actually creating a package using the file lcov_cobertura.py and not the 'module' lcov_cobertura (a __init__.py is actually missing to be a module).

Three ways to fix this issue:

cgutierr-zgz commented 2 years ago

Project has been already some months without any update to the repo so I it might be a bit discontinued

eriwen commented 2 years ago

Fixed by 3aebf295feadd48a0415041b69d698fa77a03cc5 and released in version 2.0.2 https://pypi.org/project/lcov-cobertura/2.0.2/