第一步:下载相关的源码
pycap: http://code.google.com/p/pypcap/
sendpkt: http://code.google.com/p/sendpkt/
dpkt:http://code.google.com/p/dpkt/
wdp http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip
mingw: http://www.mingw.org/
第二步: 编译
1.pycap,wdp 解压这两个文件到同一目录,注意:要到同一目录
2.在解压后的pycap文件夹中建立一个setup.cfg文件,内容为:
[build]
compiler=mingw32
3.开始编译
C:\Users\linuxany\Desktop\pypcap-1.1>python setup.py build
running build
running build_ext
building 'pcap' extension
creating build
creating build\temp.win32-2.6
creating build\temp.win32-2.6\Release
D:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\WpdPack\include -ID:\python\python2.6\include -ID:\python\python2.6\PC -c pcapc -o build\temp.win32-2.6\Release\pcap.o -DWIN32 -DWPCAP
writing build\temp.win32-2.6\Release\pcap.def
creating build\lib.win32-2.6
D:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.6\Reease\pcap.o build\temp.win32-2.6\Release\pcap_ex.o build\temp.win32-2.6\Release\pcap.def -L..\WpdPack\lib -LD:\python\python2.6\libs -LD:\pythoh\python2.6\PCbuild -lwpcap -liphlpapi -lpython26 -lmsvcr90 -o build\lib.win32-2.6\pcap.pyd
C:\Users\linuxany\Desktop\pypcap-1.1>python setup.py install
4.用同样的方法安装sendpkt
第三步:测试是否编译和安装成功
C:\Users\linuxany>python
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03)
>>> import pcap,sendpkt,dpkt
>>>