【问题标题】:Whey I get errors when running pyshark on python3 virtual env ?在 python3 virtualenv 中运行 pyspark 时出现错误?
【发布时间】:2018-09-15 22:17:10
【问题描述】:

最近我在我的 Pycharm 上安装了 Pyshark。这是我的代码:

import pyshark
cap = pyshark.FileCapture('/root/captures/initialize_db.pcap')
print (dir(cap[184]['DB-LSP-DISC']))

当我运行时,我会得到答案以及一些警告:

['DATA_LAYER', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_all_fields', '_field_prefix', '_get_all_field_lines', '_get_all_fields_with_alternates', '_get_field_or_layer_repr', '_get_field_repr', '_layer_name', '_sanitize_field_name', 'field_names', 'get', 'get_field', 'get_field_by_showname', 'get_field_value', 'json_array', 'json_key', 'json_member', 'json_object', 'json_value_number', 'json_value_string', 'layer_name', 'pretty_print', 'raw_mode']
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_events.py", line 510, in __del__
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 65, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 146, in remove_signal_handler
  File "/usr/lib/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Exception ignored in: <generator object Capture._packets_from_tshark_sync at 0x7f4787d2eba0>
Traceback (most recent call last):
  File "/root/PycharmProjects/Dropbox/venv/lib/python3.5/site-packages/pyshark/capture/capture.py", line 229, in _packets_from_tshark_sync
  File "/usr/lib/python3.5/asyncio/base_events.py", line 443, in run_until_complete
  File "/usr/lib/python3.5/asyncio/base_events.py", line 357, in _check_closed
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'Capture._cleanup_subprocess' was never awaited
Exception ignored in: <bound method BaseSubprocessTransport.__del__ of <_UnixSubprocessTransport closed pid=20639 running stdout=<_UnixReadPipeTransport closing fd=7 open>>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 131, in __del__
  File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 106, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 414, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 442, in _close
  File "/usr/lib/python3.5/asyncio/base_events.py", line 572, in call_soon
  File "/usr/lib/python3.5/asyncio/base_events.py", line 357, in _check_closed
RuntimeError: Event loop is closed

我在虚拟环境中运行 Python 3.5.3。

【问题讨论】:

    标签: python pyshark


    【解决方案1】:

    对我来说,当我将 exit() 函数放在代码末尾时,错误就消失了。我不知道为什么? (事实上​​它让我想起了这个模因:)

    https://pics.me.me/my-code-doesnt-work-ihave-noidea-why-my-code-works-28614548.png

    【讨论】:

      【解决方案2】:

      与tornado的版本有关 建议的解决方案是使用以下版本: python==3.5.2,pyshark==0.3.7.11 和 tornado==4.5.3

      【讨论】:

        猜你喜欢
        • 2019-07-22
        • 2018-07-31
        • 2014-08-11
        • 2019-01-03
        • 2015-11-08
        • 1970-01-01
        • 1970-01-01
        • 2020-09-07
        • 2022-08-02
        相关资源
        最近更新 更多