2

I am trying to install nmap package on my mac. After I had completed the installation process described on the developer's site I tried to run the following code:

import nmap
def nmapScan(tgtHost, tgtPort):
    nmScan = nmap.PortScanner()

So I got an error:

File "build/bdist.macosx-10.10-intel/egg/nmap/nmap.py", line 180, in __init__
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is :/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

Ok. I found the path to python-nmap package and added it manually to the PATH. I believe that I have to add one that contains nmap.py file. Here it is:

/Users/%username%/Documents/Python_docs/python-nmap-0.1.4/nmap 

And I am still getting the same error. Does anyone know why? Is there someone else who had this problem before? I have searched through internet and there is nothing that helps me. Thank you!

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
Petr Stepanov
  • 71
  • 2
  • 9

2 Answers2

4

You need to install the nmap first. Use this link nmap. Since the Python library invokes the nmap binary. nmap binary should be available in your system.

kvivek
  • 3,321
  • 1
  • 15
  • 17
  • Thanks a lot. I was kinda confused by the fact that this is a software distributed by other guys. Fortunately, MacPorts has this package and it is easy to install. Sorry, I cannot vote up, I gotta have higher reputation. But your answer works! – Petr Stepanov Dec 26 '14 at 08:19
0

Install nmap with homebrew and this error goes away.

brew install nmap

You can do this before or after you install python-nmap.

Daniel Lee
  • 7,189
  • 2
  • 26
  • 44