Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

('Nmap not found', <class 'nmap.nmap.PortScannerError'>)

Tags:

python

Where is the problem?

import nmap

I installed nmap and python, and when I use import nmap there is no any problem. But when use:

nmap.PortScanner()

this error is thrown:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    nmap.PortScanner()
  File "./nmap/nmap.py", line 153, in __init__
    raise PortScannerError('nmap program was not found in path. PATH is:{0}'.format(os.getenv('PATH')))
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /usr/lib    /lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:    /usr/local/games'"
like image 465
Zero Days Avatar asked Mar 11 '13 10:03

Zero Days


1 Answers

For Windows users:

I would suggest first closing all terminals and IDLE or any other window you currently have opened when trying to run your script.

Next, open a command line and type

pip uninstall python-nmap

If you are unsure if Nmap binaries are installed on your current system, do a simple search for

nmap

from your start menu. If it is installed, continue to the next step, if not, go to Nmap's official download page

Download the windows self install and run it. Record the directory it is being installed to.

Go to that directory. For me it was

C:\Program Files (x86)\Nmap

Open your system's environment variables editor usually found in

My PC > System Information > Advance settings > Environment Variables

Or right click

My PC or My Computer or whatever yours is called and select properties then advance settings then Environment Variables at the bottom of the Advanced tab

select Path for both You and the System

press Edit and enter the full path to your Nmap director

eg ;C:\Program Files (x86)\Nmap\

Press ok and exit the editor.

Now go back to your command line and enter: pip install python-nmap Allow it to install and then restart your ide and test your code again.

like image 138
Chad Mx Avatar answered Sep 19 '22 15:09

Chad Mx