Error while installing python-gvm

Hi ,
i get an error while installing python gvm with python3 -m pip install --user python-gvm

raise DistutilsOptionError("can't combine user with prefix, " distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

I have installed pip3 and python is running with version 3.8.

Has someone an idea what could cause this?

I installed a virtual environment with
virtualenv --python python3.8 /omd/sites/openvas . openvas is the user for my new Nagios-Site.
after that i did export PATH=$PATH:$USER/omd/sites/openvas/.
And so i was able to install python-gvm and gvm-tools.

Well, that what i did could be terribly wrong (yes i did a snapshot before). I do not know it better.
I thought installing a virtualenv and exporting the pythonpath to same directory could solve my problem .

Unfortunately commands with gvm-cli are not found.
I really need some help there

seems like i totally wracked it.
OMD[openvas]:~/gvm/python-gvm$ python3 -m pip install --user python-gvm
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

and i cant get rid of the virtualenv with any rm commands

is there anything i can do?

I did a fresh new setup of nagios.

Heres what i tried
OMD[openvas]:~/gvm/python-gvm$ python3 -m pip install --user python-gvm

Collecting python-gvm Using cached python_gvm-20.8.1-py3-none-any.whl (90 kB) Collecting lxml<5.0.0,>=4.5.0 Using cached lxml-4.5.2-cp38-cp38-manylinux1_x86_64.whl (5.4 MB) Collecting defusedxml<0.7.0,>=0.6.0 Using cached defusedxml-0.6.0-py2.py3-none-any.whl (23 kB) Collecting paramiko<3.0.0,>=2.7.1 Using cached paramiko-2.7.2-py2.py3-none-any.whl (206 kB) Collecting bcrypt>=3.1.3 Using cached bcrypt-3.2.0-cp36-abi3-manylinux2010_x86_64.whl (63 kB) Collecting pynacl>=1.0.1 Using cached PyNaCl-1.4.0-cp35-abi3-manylinux1_x86_64.whl (961 kB) Collecting cryptography>=2.5 Using cached cryptography-3.1-cp35-abi3-manylinux2010_x86_64.whl (2.6 MB) Collecting cffi>=1.1 Using cached cffi-1.14.2-cp38-cp38-manylinux1_x86_64.whl (410 kB) Collecting six>=1.4.1 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) Collecting pycparser Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB) Installing collected packages: lxml, defusedxml, pycparser, cffi, six, bcrypt, pynacl, cryptography, paramiko, python-gvm ERROR: Exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main status = self.run(options, args) File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 421, in run installed = install_given_reqs( File "/usr/lib/python3/dist-packages/pip/_internal/req/__init__.py", line 67, in install_given_reqs requirement.install( File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 781, in install scheme = get_scheme( File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 185, in get_scheme scheme = distutils_scheme( File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 125, in distutils_scheme i.finalize_options() File "/usr/lib/python3.8/distutils/command/install.py", line 274, in finalize_options raise DistutilsOptionError("can't combine user with prefix, " distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

Has anyone an idea?

i tried to install gvm-tools with a parameter --system, so full command was
pip3 install --user gvm-tools --system

looked good in beginning, it installed collected packages but cli commands are still not found

Hi,

this is a typical Python installation issue. You need to understand Python modules and how they get loaded from the interpreter. Python virtual environments help you to separate installations to be able to install different versions of one module. Please read https://realpython.com/python-virtual-environments-a-primer/ for an introduction to virtual environments.

To fix your issue please create a fresh new virtual Python environment, activate that environment (source /path/to/env/bin/activate), update pip in the environment (pip install -U pip) and afterwards install gvm-tools without --user switch (pip install gvm-tools). You don’t need (and even can’t use) the --user option within virtual environments. It even doesn’t make sense if you understand them.

Hi,
thank you for the answer. Ive tried out your advice, installed a new virtualenv, activated it, updated pip and installed gvm-tools inside the virtualenv
(installvirtenv) OMD[openvas]:~/gvm/installvirtenv/gvm-tools$ pip install gvm-tools

but gvm-cli is not found. i did install python-gvm inside the same environment.

Did i do something wrong?

I did not set a pythonPath yet. I am not sure where to export that path. Is it in bin directory of the virtual env?

I just did exactly the same steps on a testmachine and it works just fine.
But all i did on my nagios server was installing check_mk, creating a site with the name “gvm” and trying to install gvm-tools under the created user “gvm”

I am really not sure what you are doing. The virtualenv must be created with the same user you wanted to use gvm-tools with of course. Please just follow my advises. If you are within a virtualenv the applications are available in your PATH. You should really read the article at real python (https://realpython.com/python-virtual-environments-a-primer/) to understand virtual environments.

The User is automatically created with the new Nagios “Site”. Under this user i created a virtualenv.
I activate the virtualelenv and inside there, i updated pip and installed “python-gvm” and “gvm-tools” without --user -option.

My python executable in virtualenv (env) OMD[gvm]:~/virtualenv$ which python /opt/omd/sites/gvm/virtualenv/env/bin/python

The Path gives me (env) OMD[gvm]:~/virtualenv$ echo $PATH /opt/omd/sites/gvm/virtualenv/env/bin:/omd/sites/gvm/lib/perl5/bin:/omd/sites/gvm/local/bin:/omd/sites/gvm/bin:/omd/sites/gvm/local/lib/perl5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin, which looks in the first entry of my virtualenv.
For me it looks correct.

As i said i tried this for the user which comes with creating a new nagios site.
If i do exactly same steps with any other user which was not created by a new Site, then it works fine like it should.

best regards

so i figured check_mk includes python2 libs only.
Trying to install gvm-tools gives me the warning

WARNING: Target directory /omd/sites/gvm/local/lib/python/bin already exists. Specify --upgrade to force replacement.

check_mk community says python3 will be included in the next Version 1.7

so i think i will try to switch to Icinga2 to get the connection working between nagios and gvm

sorry for all these posts.
I installed checkmk1.7 and now it works!
Thank you for the help and understanding virtualenv :slight_smile:

1 Like