Closed landonstewart closed 2 years ago
Can you try just to import gvm? Could you print sys.path? I am really sure this is just a setup issue.
Can you try just to import gvm? Could you print sys.path? I am really sure this is just a setup issue.
Hello,
Thanks for replying. Here's some more diagnostic info:
root@5b82752f17b4:/code# python
Python 3.9.13 (main, Jul 12 2022, 12:04:02)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
>>> import gvm
>>> import gvm.connections
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gvm.connections'
root@5b82752f17b4:/code# ls -la /usr/local/lib/python3.9/site-packages/gvm/
total 72
drwxr-xr-x 4 root root 4096 Jul 28 18:39 .
drwxr-xr-x 1 root root 4096 Jul 28 18:39 ..
-rw-r--r-- 1 root root 1092 Jul 28 18:39 __init__.py
drwxr-xr-x 2 root root 4096 Jul 28 18:39 __pycache__
-rw-r--r-- 1 root root 103 Jul 28 18:39 __version__.py
-rw-r--r-- 1 root root 18680 Jul 28 18:39 connections.py
-rw-r--r-- 1 root root 5588 Jul 28 18:39 errors.py
drwxr-xr-x 6 root root 4096 Jul 28 18:39 protocols
-rw-r--r-- 1 root root 0 Jul 28 18:39 py.typed
-rw-r--r-- 1 root root 2444 Jul 28 18:39 transforms.py
-rw-r--r-- 1 root root 2897 Jul 28 18:39 utils.py
-rw-r--r-- 1 root root 4511 Jul 28 18:39 xml.py
Currently I can't reproduce your issue
> docker pull python:3.9
3.9: Pulling from library/python
d836772a1c1f: Pull complete
66a9e63c657a: Pull complete
d1989b6e74cf: Pull complete
c28818711e1e: Pull complete
5084fa7ebd74: Pull complete
7f162c881e4f: Pull complete
d5fddc3fc784: Pull complete
cdcb8ab52fb7: Pull complete
64f932c5d70e: Pull complete
Digest: sha256:10c9746c8b37dede9e91c153a04a0853264ad948de0a449e1a061d4d0e63c173
Status: Downloaded newer image for python:3.9
docker.io/library/python:3.9
> docker run -it --rm python:3.9 /bin/bash
root@9b1d46271455:/# id
uid=0(root) gid=0(root) groups=0(root)
root@9b1d46271455:/# python3 -m pip install python-gvm
Collecting python-gvm
Downloading python_gvm-22.6.1-py3-none-any.whl (137 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 137.7/137.7 KB 1.1 MB/s eta 0:00:00
Collecting lxml<5.0.0,>=4.5.0
Downloading lxml-4.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 2.9 MB/s eta 0:00:00
Collecting paramiko<3.0.0,>=2.7.1
Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 212.9/212.9 KB 438.6 kB/s eta 0:00:00
Collecting defusedxml<0.8,>=0.6
Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting cryptography>=2.5
Downloading cryptography-37.0.4-cp36-abi3-manylinux_2_24_x86_64.whl (4.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 5.5 MB/s eta 0:00:00
Collecting bcrypt>=3.1.3
Downloading bcrypt-3.2.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.3/62.3 KB 2.2 MB/s eta 0:00:00
Collecting pynacl>=1.0.1
Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 KB 5.3 MB/s eta 0:00:00
Collecting six
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cffi>=1.1
Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.2/441.2 KB 3.7 MB/s eta 0:00:00
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 KB 4.0 MB/s eta 0:00:00
Installing collected packages: six, pycparser, lxml, defusedxml, cffi, pynacl, cryptography, bcrypt, paramiko, python-gvm
Successfully installed bcrypt-3.2.2 cffi-1.15.1 cryptography-37.0.4 defusedxml-0.7.1 lxml-4.9.1 paramiko-2.11.0 pycparser-2.21 pynacl-1.5.0 python-gvm-22.6.1 six-1.16.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.
root@9b1d46271455:/# python3
Python 3.9.13 (main, Jul 12 2022, 12:04:02)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gvm.connections
>>>
again even with updating pip it's not reproducable on my side
> docker run -it --rm python:3.9 /bin/bash
root@6b6f4b1a8fd0:/# python3 -m pip install -U pip
Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (22.0.4)
Collecting pip
Downloading pip-22.2.1-py3-none-any.whl (2.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 4.5 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-22.2.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@6b6f4b1a8fd0:/# python3 -m pip install python-gvm
Collecting python-gvm
Downloading python_gvm-22.6.1-py3-none-any.whl (137 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 137.7/137.7 kB 1.3 MB/s eta 0:00:00
Collecting paramiko<3.0.0,>=2.7.1
Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 212.9/212.9 kB 1.8 MB/s eta 0:00:00
Collecting lxml<5.0.0,>=4.5.0
Downloading lxml-4.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 4.5 MB/s eta 0:00:00
Collecting defusedxml<0.8,>=0.6
Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting six
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting cryptography>=2.5
Downloading cryptography-37.0.4-cp36-abi3-manylinux_2_24_x86_64.whl (4.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 5.8 MB/s eta 0:00:00
Collecting pynacl>=1.0.1
Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 5.5 MB/s eta 0:00:00
Collecting bcrypt>=3.1.3
Downloading bcrypt-3.2.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.3/62.3 kB 2.7 MB/s eta 0:00:00
Collecting cffi>=1.1
Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.2/441.2 kB 5.4 MB/s eta 0:00:00
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 5.2 MB/s eta 0:00:00
Installing collected packages: six, pycparser, lxml, defusedxml, cffi, pynacl, cryptography, bcrypt, paramiko, python-gvm
Successfully installed bcrypt-3.2.2 cffi-1.15.1 cryptography-37.0.4 defusedxml-0.7.1 lxml-4.9.1 paramiko-2.11.0 pycparser-2.21 pynacl-1.5.0 python-gvm-22.6.1 six-1.16.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@6b6f4b1a8fd0:/# python3
Python 3.9.13 (main, Jul 12 2022, 12:04:02)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gvm.connections
>>> gvm.__file__
'/usr/local/lib/python3.9/site-packages/gvm/__init__.py'
>>> gvm.connections.__file__
'/usr/local/lib/python3.9/site-packages/gvm/connections.py'
So only thing I could image now is that you have a local python file called gvm.py
in your working dir. Would help to print
>>> import gvm
>>> gvm.__file__
I have also tried several things and could not reproduce this. I guess there is something wrong with your setup.
I am also not sure what you want to try. If you want to use the python API, maybe try to use gvm-tools, in your case probably gvm-pyshell
.
So only thing I could image now is that you have a local python file called
gvm.py
in your working dir.
Yes, sorry. That was it. There was a directory named gvm/. Python was looking there first for the rest of library.
Expected behavior
Trying to use python-gvm within a Docker container. Using python:3.9.
Current behavior
Error:
ModuleNotFoundError: No module named 'gvm.connections'
but it is installed.Steps to reproduce
Dockerfile:
Output:
GVM versions
gvm-tools: 22.6.1
python-gvm: 22.6.1
gsa: N/A cannot get this far for it to matter
gvm: N/A cannot get this far for it to matter
openvas-scanner: N/A cannot get this far for it to matter
gvm-libs: N/A cannot get this far for it to matter
Environment
Operating system: Linux 5b82752f17b4 5.4.0-107-generic #121-Ubuntu SMP Thu Mar 24 16:04:27 UTC 2022 x86_64 GNU/Linux
Installation method / source: pip
Logfiles
N/A