我在OSX10.10上使用Pyshark和Python2.6。我只是尝试在我的代码中使用import 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发布于 2015-03-04 05:34:15
该错误是由于使用introduced to Python 2 in 2.7的语言特性dictionary comprehension造成的,而不是您正在尝试使用的2.6。苹果发布了OSX10.10的2.7和2.6版本。有没有什么原因你不能用2.7来代替?
https://stackoverflow.com/questions/28841676
复制相似问题