首页 > 解决方案 > pyshark.tshark.tshark.TSharkNotFoundException: 找不到 TShark

问题描述

我正在尝试在MACOX Catlina 上使用 pyshark 运行以下代码,当我运行它时,我得到以下异常(另外我使用 sudo 在程序下面运行,以防它是由于权限问题,但给了我同样的错误)

    "Searched these paths: {}".format(possible_paths)
pyshark.tshark.tshark.TSharkNotFoundException: TShark not found. Try adding its location to the configuration file. Searched these paths: ['C:\\Program Files\\Wireshark\\dumpcap.exe', '/usr/local/bin/dumpcap', '/usr/bin/dumpcap', '/bin/dumpcap', '/usr/sbin/dumpcap', '/sbin/dumpcap', '/opt/X11/bin/dumpcap']
import pyshark

class SniffPacket(object):
    
    def __init__(self):
        self.sniff()
    
    
    def sniff(self):
        capture = pyshark.LiveCapture(interface='en0')
        capture.sniff(timeout=10)
            
if __name__ == '__main__':
    s = SniffPacket() 

我已经安装了wireshark。任何帮助表示赞赏。是因为 pyshark 不能在 Mac 上运行吗?

标签: pythonwiresharktsharkpyshark

解决方案


打开 config.ini 文件,将 tshark 路径更改为你的 tshark.exe 所在的路径。(适用于 Windows)如果这不起作用,请尝试将 dumpcap 路径也更改为存储 dumpcap.exe 的位置。


推荐阅读