Error while using dpkt in python
Question: I'm writing some code to parse a pcap file in python as follows:

    
    
    #!/usr/bin/env python
    import socket
    import dpkt
    import sys
    import pcap
    pcapReader = dpkt.pcap.Reader(file("clients.pcap", "rb"))
    for ts, data in pcapReader:
        ether = dpkt.ethernet.Ethernet(data)
        if ether.type != dpkt.ethernet.ETH_TYPE_IP: raise
        ip = ether.data
        src = socket.inet_ntoa(ip.src)
        dst = socket.inet_ntoa(ip.dst)
        print "%s -> %s" % (src, dst)
    

While compiling, I’m getting the following error message::

    
    
    Traceback (most recent call last):
      File "test.py", line 3, in <module>
        import dpkt
    ImportError: No module named dpkt
    

Any help is appreciated.


Answer: On Ubuntu, just type:

    
    
    sudo apt-get install python-dpkt
    

