I am currently learning ethical hacking with python and am trying to use Nmap however after installing it, and doing some simple scripting I get the following error:
Traceback (most recent call last):
File "nmap_test.py", line 3, in <module>
nmap1 = nmap.PortScanner()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nmap/nmap.py", line 131, in __init__
os.getenv('PATH')
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
Previous to this I got a different error saying the following:
Traceback (most recent call last):
File "nmap_test.py", line 3, in <module>
nmap1 = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'
With the bottom error I had installed just 'nmap' using pip3 (as I am using python3.7) and when that did not work I uninstalled 'nmap' and installed 'python-nmap' but then I got the top error message.
Please can someone help me out, I would greatly appreciate it. I have included my code below just for reference.
import nmap
nmap1 = nmap.PortScanner()
a = nmap1.nmap_version()
print(a)