You can read about this python module here.
First let's install this python module.
C:\Python27>cd Scripts C:\Python27\Scripts>pip install python-nmap Collecting python-nmap Downloading python-nmap-0.6.1.tar.gz (41kB) 100% |################################| 51kB 240kB/s Installing collected packages: python-nmap Running setup.py install for python-nmap ... done Successfully installed python-nmap-0.6.1About this python-nmap version you can read here.
I try to run the example source code but not of this example working.
For example I got this:
>>> nm.scan('127.0.0.1', '22-443') {'nmap': {'scanstats': {'uphosts': '1', 'timestr': 'Wed Dec 07 08:13:01 2016', ' downhosts': '-1', 'totalhosts': '0', 'elapsed': '10.74'}, 'scaninfo': {'tcp': {' services': '22-443', 'method': 'syn'}, 'error': [u'dnet: Failed to open device l o0\r\nQUITTING!\r\n', u'dnet: Failed to open device lo0\r\nQUITTING!\r\n']}, 'co mmand_line': 'nmap -oX - -p 22-443 -sV 127.0.0.1'}, 'scan': {}}