SRUCLA
SRUCLA

Reputation: 799

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. I keep getting this error

ImportError: No module named 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

Please let me know what I'm missing! #noob

Upvotes: 4

Views: 6514

Answers (3)

N. S.
N. S.

Reputation: 169

Download the latest version of pcapy from this link https://www.coresecurity.com/corelabs-research/open-source-tools/pcapy

Unpack it and from the directory run the following command:

python setup.py install

Upvotes: 0

Yoel
Yoel

Reputation: 9614

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:

$ 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

Upvotes: 4

Nazar Medeiros
Nazar Medeiros

Reputation: 445

I had the same problem. I solved this using following steps:

1.) Open terminal and enter the command

sudo pip install --user pcapy

2.) Enter

python

in your terminal

3.) Enter the command

import pcapy

This should fix your problem.

Best regards, Nazar Medeiros

Upvotes: 5

Related Questions