找不到python nmap模块

时间:2019-07-07 01:23:57

标签: python-3.x visual-studio visual-studio-2017 nmap

Python版本和pip列表如下所示

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

但是,当我尝试在代码中导入nmap模块时,会看到以下内容。

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

我在这里做什么错了?

更新
我也安装了pip3。下面是其输出,显示存在nmap模块。

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.

1 个答案:

答案 0 :(得分:1)

尝试从全局位置卸载它并将其安装到您的用户环境。

首先使用以下命令卸载pacakge:

pip3 uninstall python-nmap

然后使用--user标志重新安装它:

pip3 install --user python-namp

对于与nmap program was not found in path相关的问题

您可能要检查以下线程:Not found in path while calling PortScanner

此外python-nmap不会安装GUI版本,这可能是这里的原因。在以下位置找到安装程序:Install nmap link