3

我是 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'

我知道原因是cap里没有包,但是我的朋友可以通过pyshark读取文件

我使用 python 3.6.0 anaconda 而 pyshark 在 anaconda 中是 0.3.7

4

1 回答 1

0

如果您使用 jupyter,请在 PyShark Repo上查看此问题。我有同样的问题,好像 pyshark 不适合 jupyter。我会假设它也可能与 ipython 有相同的问题。他们的仓库中也有一些像这样的拉取请求作为修复,但还没有合并。

于 2018-11-16T01:24:25.143 回答