-1
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)

AcK
  • 2,063
  • 2
  • 20
  • 27
Yoosuf Ismath
  • 17
  • 1
  • 3

4 Answers4

0

STEP 1: Uninstall the package using:

pip3 uninstall python-nmap

STEP 2: Install the package:

pip3 install --user python-nmap
  • hmm. tried this but doesnt work. import nmap works on pycharm but not on visual studio 2019. i think my visual studio IDE does not know where to look for the libraries. pre installed libraries like socket works fine – Yoosuf Ismath Feb 19 '21 at 04:45
0

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

Yoosuf Ismath
  • 17
  • 1
  • 3
0

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
    
tripleee
  • 175,061
  • 34
  • 275
  • 318
0

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

Duncan
  • 1
  • 1
  • Why do you need to switch to superuser if you are using `sudo`? – let me down slowly Feb 19 '22 at 21:44
  • 1
    @shhh Right, you don't have to use the sudo command and thanks for pointing that out. For some reason, I needed to switch to root user for pip3 install python-nmap to work. – Duncan Feb 20 '22 at 20:23