简体   繁体   English

在Mac上安装Scapy:“ImportError:没有名为pcapy的模块”

[英]Installing Scapy on a Mac: “ImportError: No module named pcapy”

I'm trying to run a python script that involves scapy but I can't seem to get it to run. 我正在尝试运行一个涉及scapy的python脚本,但我似乎无法让它运行。 I keep getting this error 我一直收到这个错误

ImportError: No module named pcapy ImportError:没有名为pcapy的模块

The script I'm trying to run is: 我正在尝试运行的脚本是:

from scapy.all import *

def arp_display(pkt):
  if pkt[ARP].op == 1: #who-has (request)
    if pkt[ARP].psrc == '0.0.0.0': # ARP Probe
      print "ARP Probe from: " + pkt[ARP].hwsrc

print sniff(prn=arp_display, filter="arp", store=0, count=10)

I've installed XCode, XQuartz, Python, and Scapy using macports 我使用macports安装了XCode,XQuartz,Python和Scapy

Please let me know what I'm missing! 请让我知道我错过了什么! #noob #菜鸟

I had the same problem. 我有同样的问题。 I solved this using following steps: 我用以下步骤解决了这个问题:

1.) Open terminal and enter the command 1.)打开终端并输入命令

sudo pip install --user pcapy sudo pip install --user pcapy

2.) Enter 2.)输入

python 蟒蛇

in your terminal 在你的终端

3.) Enter the command 3.)输入命令

import pcapy 进口pcapy

This should fix your problem. 这应该可以解决您的问题。

Best regards, Nazar Medeiros 此致,Nazar Medeiros

Try installing libpcap and its Python wrapper from source, as listed here , though the latest version is 0.6.4 and not 0.6.2: 尝试安装的libpcap和源的Python包装,由于上市这里 ,虽然最新的版本是0.6.4,而不是0.6.2:

$ wget http://dfn.dl.sourceforge.net/sourceforge/pylibpcap/pylibpcap-0.6.4.tar.gz
$ tar xfz pylibpcap-0.6.4.tar.gz
$ cd pylibpcap-0.6.4
$ sudo python setup.py install

Download the latest version of pcapy from this link https://www.coresecurity.com/corelabs-research/open-source-tools/pcapy 从以下链接下载最新版本的pcapy https://www.coresecurity.com/corelabs-research/open-source-tools/pcapy

Unpack it and from the directory run the following command: 将其解压缩并从目录运行以下命令:

python setup.py install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM