python-3.x - 找不到python 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.
解决方案
尝试从全局位置卸载它并将其安装到您的用户环境中。
首先使用以下命令卸载 pacakge:
pip3 uninstall python-nmap
然后使用 --user 标志重新安装它:
pip3 install --user python-namp
对于您的相关问题nmap program was not found in path
您可能需要检查此线程:调用 PortScanner 时未在路径中找到
python-nmap 也没有安装 GUI 版本,这可能是这里的原因。在以下位置找到安装:安装 nmap 链接
推荐阅读
- c# - Razor 页面中确认模式后的信息模式
- html - Font Awesome 图标未显示 Impreza thme
- mysql - MySQL 还不支持 Limit&& in/all?
- python - 我如何显示在 django 中花费的平均时间(in_time 和 out_time)?我使用聚合吗?
- php - 在 csv 文件中写入结果时遇到问题
- c# - 无法在 Visual Studio 2017 中打开项目
- python - 什么是在python中调用的for循环末尾的for循环?
- c# - Linq 计数与计数()
- python - TypeError: src2 不是 numpy 数组,也不是标量
- java - 带有 HikariCP 的 Java Spring Boot postgresql - 从语句查询中获取原始字符串输出