Scapy error: no module names pcapy

Prakhar Mohan Srivastava picture Prakhar Mohan Srivastava · Feb 11, 2014 · Viewed 24k times · Source

The code given below is for sniffing a packet from the IP address provided.

from scapy.all import *

sniff(filter="tcp and host 192.168.0.90", count=10)

On running this code the error I am getting is:

Traceback (most recent call last):   File ".\sample.py", line 1, in <module>
    from scapy.all import *   File "C:\Python27\lib\site-packages\scapy\all.py", line 16, in <module>
    from arch import *   File "C:\Python27\lib\site-packages\scapy\arch\__init__.py", line 79, in <module>
    from windows import *   File "C:\Python27\lib\site-packages\scapy\arch\windows\__init__.py", line 23, in <module>
    from scapy.arch import pcapdnet   File "C:\Python27\lib\site-packages\scapy\arch\pcapdnet.py", line 30, in <module>
    import pcapy as pcap ImportError: No module named pcapy

Where am I going wrong? I am using windows 7 for this.

Answer

Bhavesh Odedra picture Bhavesh Odedra · Feb 11, 2014

try this to import For Ubuntu

$ sudo apt-get install python-pcapy

You can also build it from source:

$ sudo pip install "http://corelabs.coresecurity.com/index.php?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-0.10.8.tar.gz"

And here is good documentation of Scapy. http://www.secdev.org/projects/scapy/doc/installation.html

For Windows, you can download and run setup.py file from the below link as per your requirement version.

http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy 

http://breakingcode.wordpress.com/2012/07/16/quickpost-updated-impacketpcapy-installers-for-python-2-5-2-6-2-7/