-1

Is it possible that Nmap doesn't work on windows with python 3.6? Nmap folders are installed but I still get an error message. I tried in console python -m pip install nmap and also python -m pip install python-nmap.

I tried this script from an earlier post:

import nmap
nm = nmap.PortScanner()

for host in nm.all_hosts():
    print(host)
    print(nm[host].get('osclass', 'unknown'))

Here is the error:

Traceback (most recent call last):
  File "C:\Users\bart\Desktop\vortex\nmap script 1.py", line 2, in <module>
    nm = nmap.PortScanner()
  File "C:\Users\bart\AppData\Local\Programs\Python\Python36\lib\site-packages\nmap\nmap.py", line 131, in __init__
    os.getenv('PATH')
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is :
bonsaiviking
  • 5,825
  • 1
  • 20
  • 35
Bart1986
  • 31
  • 2
  • 7
  • What is actually in the PATH variable? Did you install Nmap from https://nmap.org/download.html#windows ? The `python-nmap` library does not include the Nmap program; it is only an interface, not the program itself. – bonsaiviking Jul 21 '17 at 18:31
  • I did not install Nmap , i thought the python -m pip install nmap was the whole thing. Thx fixed it for me – Bart1986 Jul 30 '17 at 19:03
  • Anser 1 is correct, however I needed to put in the code "nm.scan()" between the declaration and the loop to make the above code snippet function properly. If you use the NMAP installer provided at NMAP.ORG, it will update your path and handle your situation and avoid your difficulty, which I shared. – Hugh Rasmussen Jan 06 '19 at 03:22

1 Answers1

1

I had the same problem, I did this and it worked for me.

Open Command Prompt and run following command

  1. pip uninstall python-nmap
  2. cd ../..
  3. pip install python-nmap
  4. nmap -V

If you can see the version then python-nmap is in your PATH

Reason I am making here uninstall first to make sure to just not user installed have access to python-nmap. Then using "cd ../.." to go the "C:" drive and then install "python-map" so now it can be added to the path.

trytry
  • 11
  • 1