why is my Nmap module not working in python 3.7

对着背影说爱祢 提交于 2020-01-06 08:52:05

问题


I am currently learning ethical hacking with python and am trying to use Nmap however after installing it, and doing some simple scripting I get the following error:

Traceback (most recent call last):
  File "nmap_test.py", line 3, in <module>
    nmap1 = nmap.PortScanner()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nmap/nmap.py", line 131, in __init__
    os.getenv('PATH')
nmap.nmap.PortScannerError: 'nmap program was not found in path. PATH is : /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

Previous to this I got a different error saying the following:

Traceback (most recent call last):
  File "nmap_test.py", line 3, in <module>
    nmap1 = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'

With the bottom error I had installed just 'nmap' using pip3 (as I am using python3.7) and when that did not work I uninstalled 'nmap' and installed 'python-nmap' but then I got the top error message.

Please can someone help me out, I would greatly appreciate it. I have included my code below just for reference.

import nmap

nmap1 = nmap.PortScanner()

a = nmap1.nmap_version()

print(a)

回答1:


The top error message,

nmap program was not found

is because the nmap application does not exist, even though the nmap.py module exists. To fix it you have to install the nmap application:

$ brew install nmap




回答2:


There are two types of nmpas

uninstall nmap

pip uninstall nmap

then install

pip install python-nmap

still use import nmap though



来源:https://stackoverflow.com/questions/54008719/why-is-my-nmap-module-not-working-in-python-3-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!