Search code examples
python-3.xvisual-studiovisual-studio-2017nmap

python nmap module could not be found


Python version and pip list are shown below

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>python --version
Python 3.6.6

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Package     Version
----------- -------
pip         19.1.1
python-nmap 0.6.1
setuptools  28.8.0

However, when I try to import nmap module in the code, I see following.

No module named 'nmap'
Stack trace:
 >  File "C:\Users\root\source\repos\PythonApplication3\PythonApplication3\PythonApplication3.py", line 1, in <module>
 >    import nmap

What am I doing wrong here?

UPDATE
I have pip3 installed as well. Below is its output showing nmap module is present.

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64>pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.3)
python-nmap (0.6.1)
setuptools (39.0.1)
You are using pip version 9.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Solution

  • Try to uninstall it from the global location and install it to your user environment.

    First uninstall the pacakge using:

    pip3 uninstall python-nmap
    

    Then re-install it using --user flag:

    pip3 install --user python-namp
    

    For your issue related to nmap program was not found in path

    You may want to check this thread: Not found in path while calling PortScanner

    Also python-nmap does not install the GUI version which might be in cause here. Find the install at: Install nmap link