Accessing zap2 in script

17 views
Skip to first unread message

ABHISHEK KUMAR

unread,
Jul 4, 2024, 6:32:50 AM (2 days ago) Jul 4
to ZAP Developer Group
Hi All,

I am starting with ZAP scripting.
For that, I am installing zap using the command pip install zaproxy .

In the terminal (VSCode), I am getting the following message:
Requirement already satisfied: zaproxy in c:\users\abhishek.kumar\appdata\local\programs\python\python311\lib\site-packages (0.3.2)
Requirement already satisfied: requests<3.0.0,>=2.31.0 in c:\users\abhishek.kumar\appdata\local\programs\python\python311\lib\site-packages (from zaproxy) (2.32.3)
Requirement already satisfied: six<2.0.0,>=1.16.0 in .............

But when I run the script, like below
import importlib.util
import importlib

if importlib.util.find_spec('zapv2') is None:
    print("zapv2 module is not installed")
else:
    print("zapv2 module is installed") 

It logs zapv2 module is not installed

I am unable to resolve this.

Following are the things I have tried:
1. Uninstalling all the versions of Python
2. Installing the latest version of Python.
3. Re-starting the system.

Regards
Abhishek

psiinon

unread,
Jul 4, 2024, 10:30:02 AM (2 days ago) Jul 4
to OWASP ZAP Developer Group

Try using

  • from zapv2 import ZAPv2

Cheers

Simon


--
For commerical ZAP support options see https://www.zaproxy.org/support/
ZAP is supported by the Crash Override Open Source Fellowship https://crashoverride.com/open-source?zap=dev
---
You received this message because you are subscribed to the Google Groups "ZAP Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zaproxy-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/zaproxy-develop/5830b98b-b950-4d20-8b2d-a8cbaad728c6n%40googlegroups.com.

ABHISHEK KUMAR

unread,
Jul 4, 2024, 9:07:38 PM (2 days ago) Jul 4
to zaproxy...@googlegroups.com
Hi,

I tied it and got the following message:

Import "zapv2" could not be resolvedPylancereportMissingImports

Regards
Abhishek

You received this message because you are subscribed to a topic in the Google Groups "ZAP Developer Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/zaproxy-develop/r84_U661d_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to zaproxy-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/zaproxy-develop/CAORxfg5kOXwVk%3D8wo0E%3DqRZkaRguSKXwwB6xKkh6RsxXF%2BH0UQ%40mail.gmail.com.

P.H.Moe

unread,
Jul 5, 2024, 5:08:25 AM (20 hours ago) Jul 5
to ZAP Developer Group
Hi,

It is most likely related to the issue with the Python and the pip install. IMO, using the virtualenv approach will be easier to fix it.
  1. Create a virtualenv in the repo/ folder where you had your source code (https://docs.python.org/3/library/venv.html)
  2. Initiate the virtualenv
  3. pip install on the zap package
  4. run the script
Best regards,
Moe

Reply all
Reply to author
Forward
0 new messages