Windows下安装使用Pypcap

在百度和google上这方面的资料也很少。而且都还是用python2.7+WinPcap的方案

安装时遇到很多问题 便记录了下来

运行pip3 install pypcap时出现错误提示

TypeError: expected str, bytes or os.PathLikeobject, not NoneType
pcap.h not found
https://nmap.org/npcap/#download 安装Npcap 并下载Npcap SDK

将下载的SDK解压到 python目录里的include

将npcap-sdk-0.1 文件夹名字改成wpdpack

pcapy模块的安装也可以参照该文,不过安装pcapy需要将wpdpack放置到C盘

重试安装报了

error:Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++

BuildTools": http://landinghub.visualstudio.com/visual-cpp-build-tool

打开http://landinghub.visualstudio.com/visual-cpp-build-tools 安装Visual C++ 2015 Build Tools

重试装pypcap

由于安装时我没有选择SDK后来爆了个错误

fatalerror C1083: Cannot open include file: 'basetsd.h': No such file or directory

我选择装Windows10 SDK解决

继续安装pypcap报

    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_freealldevs
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_datalink
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_dispatch
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_setfilter
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_open_live
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_geterr
    pcap.obj : error LNK2001: unresolved external symbol __imp_bpf_filter
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_sendpacket
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_findalldevs
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_open_offline

    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_compile
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_close
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_snapshot
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_freecode
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_lookupnet
    pcap.obj : error LNK2001: unresolved external symbol __imp_pcap_stats
    pcap_ex.obj : error LNK2001: unresolved external symbol __imp_pcap_next_ex
    pcap_ex.obj : error LNK2001: unresolved external symbol __imp_pcap_getevent
    pcap_ex.obj : error LNK2001: unresolved external symbol __imp_pcap_setmintoc
opy
    build\lib.win-amd64-3.6\pcap.cp36-win_amd64.pyd : fatal error LNK1120: 19 un
resolved externals

检查执行的命令,翻看下链接库

发现include\wpdpack\Lib 发现里面还有个64位的版本,将里面的文件复制出来覆盖了

再次编译安装 终于通过



你可能感兴趣的:(Python)