pythonwiresharktsharkpyshark

pyshark.tshark.tshark.TSharkNotFoundException: TShark not found


I am trying to run below code using pyshark on MACOX Catlina , when I run it I get the below exception (Also I ran below program using sudo ,incase if it was issue due to permission,but gives me same error)

    "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() 

I already have wireshark installed . Any help is appreciated . Is it because pyshark doesn't work on Mac ?


Solution

  • Open config.ini file and change the tshark path to the path where your tshark.exe is located. (Worked for Windows) If this doesn't work try changing the dumpcap path also to the location where dumpcap.exe is stored.