Gvm-tools errors using Python 3.7

GVM versions

gsa: Greenbone Security Assistant 9.0
gvm: Greenbone Vulnerability Manager 9.0.0
openvas-scanner: OpenVAS 7.0.0
gvm-libs: GVM Libraries 11.0.0

Environment

Operating system: Ubuntu Server 18.04 LTS
Kernel: Linux gvm 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Installation method / source: Installed GVM 11 stable from source: GVM 11 (stable, initial release 2019-10-14)

Hello Greenbone team and community,

I have a working GVM 11 system and want to use the cli and the scripting engine provided by gvm-tools.

I tried to install the gvm-tools version linked in the GVM 11 stable release post.

I followed the setup steps mentioned in the official documentation and payed attention to the requirements section (Python 3.5 and above). I choose installation for current user (not system wide) as mentioned in the documentation.

I have a default python installtion. No modifications to python were made.

When I try to run gvm-tools I am getting various errors.

gvm@gvm:~# python -V
Python 3.7.5
gvm@gvm:~$ pip -V
pip 20.0.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
gvm@gvm:~$ pip install --user gvm-tools
Collecting gvm-tools
  Downloading gvm_tools-2.0.0-py3-none-any.whl (33 kB)
Requirement already satisfied: python-gvm in /usr/local/lib/python3.7/dist-packages (from gvm-tools) (1.3.0)
Requirement already satisfied: defusedxml in /usr/lib/python3/dist-packages (from python-gvm->gvm-tools) (0.5.0)
Requirement already satisfied: paramiko in /usr/lib/python3/dist-packages (from python-gvm->gvm-tools) (2.0.0)
Requirement already satisfied: lxml in /usr/lib/python3/dist-packages (from python-gvm->gvm-tools) (4.2.1)
Installing collected packages: gvm-tools
Successfully installed gvm-tools-2.0.0

When I try to run commands provided by gvm-tools I am getting errors.

gvm@gvm:~$ gvm-cli --help
Traceback (most recent call last):
  File "/opt/gvm/.local/bin/gvm-cli", line 5, in <module>
    from gvmtools.cli import main
  File "/opt/gvm/.local/lib/python3.7/site-packages/gvmtools/cli.py", line 25, in <module>
    from gvm.protocols.latest import Osp
  File "/usr/local/lib/python3.7/dist-packages/gvm/protocols/latest.py", line 37, in <module>
    from .gmpv9 import (
  File "/usr/local/lib/python3.7/dist-packages/gvm/protocols/gmpv9/__init__.py", line 34, in <module>
    from gvm.xml import XmlCommand
  File "/usr/local/lib/python3.7/dist-packages/gvm/xml.py", line 21, in <module>
    import defusedxml.lxml as secET
  File "/usr/lib/python3/dist-packages/defusedxml/lxml.py", line 13, in <module>
    from lxml import etree as _etree
ImportError: cannot import name 'etree' from 'lxml' (/usr/lib/python3/dist-packages/lxml/__init__.py)
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/opt/gvm/.local/bin/gvm-cli", line 5, in <module>
    from gvmtools.cli import main
  File "/opt/gvm/.local/lib/python3.7/site-packages/gvmtools/cli.py", line 25, in <module>
    from gvm.protocols.latest import Osp
  File "/usr/local/lib/python3.7/dist-packages/gvm/protocols/latest.py", line 37, in <module>
    from .gmpv9 import (
  File "/usr/local/lib/python3.7/dist-packages/gvm/protocols/gmpv9/__init__.py", line 34, in <module>
    from gvm.xml import XmlCommand
  File "/usr/local/lib/python3.7/dist-packages/gvm/xml.py", line 21, in <module>
    import defusedxml.lxml as secET
  File "/usr/lib/python3/dist-packages/defusedxml/lxml.py", line 13, in <module>
    from lxml import etree as _etree
ImportError: cannot import name 'etree' from 'lxml' (/usr/lib/python3/dist-packages/lxml/__init__.py)

Any ideas on how to fix this? Is gvm-tools incompatible with Python 3.7?

Any help / advices would be greatly appreciated.

Thanks in advance!

Greetings,
ri-pa

Could you open your python interpreter and run from lxml import etree

python3
>> from lxml import etree

If you get a traceback then something is wrong with your python setup.

2 Likes

Hi bricks,

ā€œfrom lxml import etreeā€ indeed gave me a traceback.

The problem was in my setup indeed. I have multiple Python versions installed side by side and it tried to use the libraries of another Python version even though I set Python 3.7 as the main version.

Re-installing the dependencies using pip3.7 with -I flag (ignore already installed) solved the problem for me.

Thanks alot for pushing me into the right direction!!

Greetings

1 Like