skip to Main Content

I am trying to make a nmap scanner for the InfoSec Certification on freeCodeCamp.org and cannot get Visual Studio Code to recognize that I have installed nmap. I am very beginner and in the process of learning.

from cProfile import run
import nmap

scanner = nmap.PortScanner()

print("Welcome, this is a simple automattion tool")
print("<------------------------------------------->")

When I run this in VS Code I get the following in the terminal:

PS C:UsersmjameOneDriveDocumentsJimCodingfcc_python_for-pen_testingnmap_scanner_1> python3 scanner.py
Traceback (most recent call last):
  File "C:UsersmjameOneDriveDocumentsJimCodingfcc_python_for-pen_testingnmap_scanner_1scanner.py", line 2, in <module>
    import nmap
ModuleNotFoundError: No module named 'nmap'
PS C:UsersmjameOneDriveDocumentsJimCodingfcc_python_for-pen_testingnmap_scanner_1>

I have so far:

  1. Updated to the current Python 3.10.7
  2. Installed Nmap the first time from https://nmap.org/ for Windows
  3. Uninstalled Nmap
  4. Reinsalled Nmap using >>>pip3 install python-nmap

2

Answers


  1. It seems that Python cannot find nmap module.

    You can either add it to path in Windows via Start -> Edit system environment variables -> Environment variables… and then edit PATH VARIABLE by adding at the end path to nmap module that you have installed or move the module to default Python modules directory which should be C:UsersYourLoginAppDataLocalProgramsPythonPython310Libsite-packages

    Login or Signup to reply.
  2. For future searchers (as in my comment above), if you installed a module with pip3 but are still getting module import errors, try python3 -m pip install <module-name>.

    Not sure how/why this happens (pip3 installing somewhere that python3 is not looking for modules – maybe PYTHONPATH-related), but the above can [usually] help.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search