Why does pyshark throw a process error here

154 Views Asked by At

I wanted to use pyshark to capture network traffic, so naturally I searched first for the most simple examples. Having found a recipe to make a daily cron job, i changed it to capture for a minute.

import pyshark

file = 'c:\\qu\\test.pcap'
output = open(file, "w")
time = 60
capture = pyshark.LiveCapture(interface="WiFi", output_file=file)
capture.sniff(timeout=time)
output.close()

of course, it didn't work! but this error message totally threw me. What does it mean?

c:\Users\userad>py shark1.py
Traceback (most recent call last):
  File "c:\Users\usera\shark1.py", line 5, in <module>
    capture = pyshark.LiveCapture(interface="WiFi", output_file=file)
  File "C:\Python39\lib\site-packages\pyshark\capture\live_capture.py", line 58, in __init__
    all_interfaces = get_tshark_interfaces(tshark_path)
  File "C:\Python39\lib\site-packages\pyshark\tshark\tshark.py", line 114, in get_tshark_interfaces
    tshark_interfaces = subprocess.check_output(parameters, stderr=null).decode("utf-8")
  File "C:\Python39\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Python39\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:/Program Files/Wireshark/tshark.exe', '-D']' returned non-zero exit status 2.
0

There are 0 best solutions below