找不到 python scapy.all 文件

问题描述

我试过运行我的程序,我试过 import Condition list comprehension: 1.7542460000000002 C:\Users\x\x\x\x\envs\lib\timeit.py:15: UserWarning: Boolean Series key will be reindexed to match DataFrame index. -n/--number N: how many times to execute 'statement' (default: see below) C:\Users\x\x\x\x\envs\lib\timeit.py:16: UserWarning: Boolean Series key will be reindexed to match DataFrame index. -r/--repeat N: how many times to repeat the timer (default 5) Condition and drop: 5.7606202 Group by: 0.44012989999999874 然后 import scapy 但它会给我同样的错误。如果有帮助,我正在使用 kali-linux。导致错误代码来自 scapy.all

这是完整的错误输出

scapy.all import *

修复了它。你需要去:

Traceback (most recent call last):
  File "/home/bradz/test.py",line 24,in <module>
    from scapy.all import send,IP,TCP,ARP
  File "/usr/local/lib/python3.9/dist-packages/scapy/all.py",line 16,in <module>
    from scapy.arch import *
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py",line 27,in <module>
    from scapy.arch.bpf.core import get_if_raw_addr<br/>
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py",line 30,in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py",line 341,in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py",line 147,in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py",line 99,in _is_elf
    with open(filename,'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

并编辑该行

/usr/lib/python3/dist-packages/scapy/arch/bpf/core.py

LIBC = cdll.LoadLibrary(find_library("libc"))

解决方法

这似乎是库中的一个错误 fixed 11 days ago

Python 3.9 中有一个回归,find_library() 功能:

>>> import ctypes.util
>>> ctypes.util.find_library("libc")
 Traceback (most recent call last):
   File "<stdin>",line 1,in <module>
   File "/usr/lib/python3.9/ctypes/util.py",line 341,in find_library
     _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
   File "/usr/lib/python3.9/ctypes/util.py",line 147,in _findLib_gcc
     if not _is_elf(file):
   File "/usr/lib/python3.9/ctypes/util.py",line 99,in _is_elf
     with open(filename,'br') as thefile:
 FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

一种解决方法是改用 find_library("c")。它也适用于 旧版本的 Python 已经在使用了 contrib/isotp.py

更新 scapy,因为您使用的 scapy 版本似乎与您的 CPython 版本不兼容。


实际上,PyPI 似乎尚未更新,因此您将无法通过 pip 进行更新。您可能需要回滚 Python 版本,直到它更新,或者 manually install the patched scapy version from Github