'How to fix "No module named 'nmap'"

import nmap
ModuleNotFoundError: No module named 'nmap'

the above is the result when trying to run the code after importing nmap. (I have installed python-nmap using pip in cmd)



Solution 1:[1]

i found out the issue. when i chose a python env eg- python 3.8 32bit from the IDE, i chose a custom version thats why the imports dont work. when i chose the default env it worked. anyways thank for the help. there is nothing wrong with the IDE

Solution 2:[2]

I had to do two things to get it working:

  1. Install the latest version of Python3 (3.9.6) https://www.python.org/downloads/release/python-396/

  2. On your terminal:

    pip3 install python-nmap
    

Solution 3:[3]

I had to do the following to get things to work:

  1. On your terminal, switch to root privilege: su - root

  2. Then, install python-nmap module: pip3 install python-nmap

Reference: https://github.com/securipy/nmap-scan/issues/26

Solution 4:[4]

STEP 1: Uninstall the package using:

pip3 uninstall python-nmap

STEP 2: Install the package:

pip3 install --user python-nmap

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yoosuf Ismath
Solution 2 tripleee
Solution 3
Solution 4 Vinícius Cerqueira Bonifácio