首页 > 解决方案 > 为什么我不能在这个简单的应用程序中使用 scapy 模块?引发异常

问题描述

我是 Python 的新手,我发现在我正在处理的应用程序中使用scapy模块时遇到了一些困难。我在 Kali Linux 系统上使用 PyCharm 在 Python 3 中进行开发。

我安装了执行此命令的scapy :

pip install scapy-python3
Collecting scapy-python3
  Downloading https://files.pythonhosted.org/packages/4f/f3/e33d21e25b0dda2ffeebcc3ad06d26eff7f913c9b8b397c30f443b68b8e4/scapy-python3-0.26.tar.gz
Installing collected packages: scapy-python3
  Running setup.py install for scapy-python3 ... done
Successfully installed scapy-python3-0.26

好的,这是我的代码:

#!/usr/bin/env python

import scapy.all as scapy

def scan(ip):
    scapy.arping(ip)

scan("MY_IP_ADDRESS")

问题是从 PyCharm 运行此脚本时,我收到以下错误消息:

/root/Documents/PycharmWS/network_scanner/venv/bin/python /root/Documents/PycharmWS/network_scanner/network_scanner.py
Traceback (most recent call last):
  File "/root/Documents/PycharmWS/network_scanner/network_scanner.py", line 3, in <module>
    import scapy.all as scapy
  File "/root/Documents/PycharmWS/network_scanner/venv/lib/python3.7/site-packages/scapy/all.py", line 5, in <module>
    raise Exception(msg)
Exception: 
        PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. 
You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy).  


        PIP package scapy-python3 used to provide scapy3k, which was a fork from scapy implementing python3 compatibility since 2016. This package was included in some of the Linux distros under name of python3-scapy. Starting from scapy version 2.4 (released in March, 2018) mainstream scapy supports python3. To reduce any confusion scapy3k was renamed to kamene. 
You should use either pip package kamene for scapy3k (see http://github.com/phaethon/kamene for differences in use) or mainstream scapy (pip package scapy, http://github.com/secdev/scapy).  


Process finished with exit code 1

为什么?怎么了?我错过了什么?我该如何尝试解决此问题?

标签: pythonpython-3.xpipscapypython-module

解决方案


推荐阅读