3

I'm new with pyshark, and I write a sample code by searching on the tutorial

import pyshark
cap = pyshark.FileCapture("input.cap")
cap_1 = cap[0]

and then it give me an error

/Users/tingyugu/anaconda3/bin/python /Users/tingyugu/PycharmProjects/final/test.py
Traceback (most recent call last):
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 70, in __getitem__
next(self)
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 60, in __next__
packet = self._packet_generator.send(None)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tingyugu/PycharmProjects/final/test.py", line 5, in <module>
cap_1 = cap[0]
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 73, in __getitem__
raise KeyError('Packet of index %d does not exist in capture' % packet_index)
KeyError: 'Packet of index 0 does not exist in capture'

I know the reason is that there is no packets in the cap, but my friend can read the file by pyshark

I use the python 3.6.0 anaconda and the pyshark is 0.3.7 in anaconda

tingyu gu
  • 73
  • 8
  • The error message seems pretty clear. What do you mean your friend can read the file? – Gus Dec 14 '17 at 01:50

1 Answers1

0

if you are on jupyter see this issue on PyShark Repo. I had the same problem, seems like pyshark does not go well with jupyter. I'm gonna assume it might have same issues with ipython as well. there are some pull requests like this one on their repo too as a fix but nothing merged yet.

Omid S.
  • 731
  • 7
  • 15