skip to Main Content

I’m trying to use this Python libpcap library:

https://pypi.org/project/python-libpcap/

I have installed using:

sudo apt-get install libpcap-dev
pip3 install python-libpcap

but when I run the capture example code in script using sudo python3:

from pylibpcap.pcap import sniff

for plen, t, buf in sniff("my_interface", count=-1, promisc=1, out_file="pcap.pcap"):
    print("[+]: Payload len=", plen)
    print("[+]: Time", t)
    print("[+]: Payload", buf)

I get this error:

   from pylibpcap.pcap import sniff
ModuleNotFoundError: No module named 'pylibpcap'

How can I fix this/what’s wrong?

I’m on Ubuntu 22.04.

2

Answers


  1. Try this

    pip3 install python-libpcap --user
    
    Login or Signup to reply.
  2. I look up the manual for you quickly and tried to install the software on my own Mac to repeat the issue and help troubleshooting. But the installation was not even successful.

    I took another look at their website and it appears to only support up to python 3.7. Based on your sys info, it looks like you have python 3.10 installed.

    I suggested you to install python 3.6 or 3.7 then try this package again. Best luck!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search