gpt4 book ai didi

python - 为什么我在 python3 virtualenv 中运行 pyspark 时出错?

转载 作者:太空宇宙 更新时间:2023-11-04 00:11:41 25 4
gpt4 key购买 nike

最近我在我的 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。

最佳答案

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

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

关于python - 为什么我在 python3 virtualenv 中运行 pyspark 时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52349337/

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