问题描述
我正在使用Ubuntu 12.04,并安装了python-nmap来创建脚本.如果我使用IDLE并输入以下内容,则可以正常运行:
I'm using Ubuntu 12.04 and installed python-nmap to create a script. If I use IDLE and type in the following, it runs fine:
import nmap
nm = nmap.PortScanner()
nm.scan('127.0.0.1', '22-443')
但是,如果我在Eclipse中执行此操作,则会收到以下错误:
However, if I perform this in Eclipse, I receive the following error:
Traceback (most recent call last):
File "/home/russ/workspace/ViPyNmap/MyFiles/nmaptest.py", line 2, in <module>
nm = nmap.PortScanner()
AttributeError: 'module' object has no attribute 'PortScanner'
我已经将egg文件和文件夹添加到了项目的Eclipse路径中,但是没有运气.这样做之后,我也重新启动了Eclipse,但是没有运气.对于我对Eclipse和Python的经验不足,我深表歉意,并感谢您的帮助.
I've added the egg file and also the folder to the Eclipse path for the project, with no luck. I've also restarted Eclipse after doing so, with no luck. I apologize for my inexperience with both Eclipse and Python and appreciate the help.
推荐答案
您可能安装了软件包"nmap",而不是"python-nmap":
You likely installed the package "nmap", not "python-nmap":
因此,只需卸载"nmap"并安装"python-nmap":
So, just uninstall "nmap" and install "python-nmap":
pip uninstall nmap
pip install python-nmap
这篇关于“模块"对象没有属性"PortScanner"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!