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!

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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!
0

Install nmap with homebrew and this error goes away.

brew install nmap

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.