【已解决】AttributeError: module ‘nmap‘ has no attribute ‘PortScanner‘

2023-05-16

文章目录

    • 报错
    • 解决方案
      • 必要的解决方法
        • 下载安装nmap
        • 代码中添加exe路径
      • 可能有用的解决方法

报错

AttributeError: module ‘nmap’ has no attribute ‘PortScanner’

解决方案

必要的解决方法

抛出异常的原因是因为没有指定nmap的执行路径所致,在windows下需要手动指定nmap的执行路径。

下载安装nmap

https://nmap.org/download.html

代码中添加exe路径

nm = nmap.PortScanner(nmap_search_path=('nmap',r"F:\Nmap\nmap.exe"))

可能有用的解决方法

对应的应为python-nmap包,而非nmap包

pip uninstall nmap
pip install python-nmap

可能需要重启一下电脑
Good Luck!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【已解决】AttributeError: module ‘nmap‘ has no attribute ‘PortScanner‘ 的相关文章

随机推荐