我是pyshark的新手,我通过搜索教程编写示例代码
import pyshark
cap = pyshark.FileCapture("input.cap")
cap_1 = cap[0]
然后它给我一个错误
/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'
我知道原因是上限中没有数据包,但我的朋友可以通过pyshark读取该文件
我使用python 3.6.0 anaconda,而anysonda中的pyshark是0.3.7
答案 0 :(得分:0)
如果使用jupyter,请参阅PyShark Repo上的this issue。我遇到了同样的问题,似乎pyshark与jupyter配合得不好。我将假设它也可能与ipython出现相同的问题。 仓库中也有一些拉请求,例如this one作为修复,但尚未合并。