gpt4 book ai didi

python - 导入 Pyshark 时遇到问题

转载 作者:行者123 更新时间:2023-12-01 04:48:51 27 4
gpt4 key购买 nike

我在 OS X 10.10 上使用 Pyshark 和 Python 2.6。我只是尝试在代码中导入 pyshark,然后抛出此错误。知道可能出了什么问题吗?

/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 "/Users/spencergardner/Google Drive/development/python-sockets/sniff.py"
Traceback (most recent call last):
File "/Users/spencergardner/Google Drive/development/python-sockets/sniff.py", line 1, in <module>
import pyshark
File "/Library/Python/2.6/site-packages/pyshark/__init__.py", line 1, in <module>
from pyshark.capture.live_capture import LiveCapture
File "/Library/Python/2.6/site-packages/pyshark/capture/live_capture.py", line 1, in <module>
from pyshark.capture.capture import Capture
File "/Library/Python/2.6/site-packages/pyshark/capture/capture.py", line 12, in <module>
from pyshark.tshark.tshark_xml import packet_from_xml_packet, psml_structure_from_xml
File "/Library/Python/2.6/site-packages/pyshark/tshark/tshark_xml.py", line 5, in <module>
from pyshark.packet.layer import Layer
File "/Library/Python/2.6/site-packages/pyshark/packet/layer.py", line 57
return {slot: getattr(self, slot) for slot in self.__slots__}
^
SyntaxError: invalid syntax

最佳答案

该错误是由于使用 dictionary comprehension ,一个语言功能是 introduced to Python 2 in 2.7 ,而不是您尝试使用的 2.6。 Apple 发布了 OS X 10.10 以及 2.7 和 2.6。有什么理由不能使用 2.7 来代替吗?

关于python - 导入 Pyshark 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28841676/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com