How to install Python libpcap module on Mac OS X

Kuaaaly picture Kuaaaly · Nov 26, 2014 · Viewed 13.4k times · Source

I started to work on a python sniffer project. I want to use the pcap module but my computer always says "No module named pcap". I read that libpcap and pcap come with OS X but actually, it doesn't work...

I made a lot of research on the web and still unable tu run my python code. How am I supposed to do for running / linking or installing pcap ?

Note that I recently update to OSX Yosemite (but I didn't know if pcap worked before).

Answer

Kuaaaly picture Kuaaaly · Nov 26, 2014
  1. Install brew from here
  2. Run brew doctor from terminal
  3. Solve the warnings from brew doctor results
  4. Run sudo easy_install pyrex
  5. Run sudo easy_install pypcap

=> This solved my problem (don't really know if brew is necessary)