-3

So i created a code to track ips but am getting a error the code is

import socket
import os
import sys
import nmap
import time
from datetime import datetime
from urllib import request as urlrequests
def tracker():
    soc = socket.socket()
    Sc = nmap.PortScanner()
    print("[$]----Session started---->")
    ip = input("[?]Enter your I.P to Listen on: ") 
 
    try: 
        host = ip
        port = 80
 
        soc.bind((host, 80))
        print("[+] Listening on "+ ip + "....")
        
    except:
        sys.exit("[!]I.P Busy or any other network issue")
        sys.exit(0)
 
    while True:
                
        try:
            soc.listen(5)
            conn, address = soc.accept()
            print("[+] IP Logged " + str(address[0]))
            recon = Sc.scan(address[0],arguments='-O')
            print(str(address[0]) + " OS details : " + recon['scan'][address[0]]['osmatch'][0]['osclass'][0]['osfamily'])
                        
                                        
        except:
            pass
            print("[^]<----Interrupt occured terminating session---->")
            sys.exit(0)
 
tracker()

but its showing a error the error its below i cant understand why its showing this error but am trying to fix it.

Import "nmap" could not be resolved from source
  • check where you have named a file `nmap` and if the python module nmap is actually installed, can you do the import from the REPL prompt (python.exe) – rioV8 Sep 17 '21 at 05:58
  • Are you sure you have `nmap` installed? https://pypi.org/project/python-nmap/ – deponovo Sep 17 '21 at 06:14

1 Answers1

0

Make sure you have installed the package:

enter image description here

Otherwise you need to install it through: pip install python-nmap like deponovo has mentioned.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13