简体   繁体   English

python scapy.all 文件未找到

[英]python scapy.all file not found

I have tried to run my program, and I have tried import scapy then import scapy.all but is will give me the same error.我试图运行我的程序,我尝试过 import scapy然后 import scapy.all ,但它会给我同样的错误。 I am using kali-linux if that helps.如果有帮助,我正在使用 kali-linux。 The code that is causing the error is just from scapy.all import *导致错误的代码只是来自scapy.all import *

This is the full error output:这是完整的错误 output:

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'

Fixed it.解决它。 You need to go to:您需要 go 来:

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

and edit the line并编辑该行

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

to

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

This appears to have been a bug in the library that was fixed 11 days ago :这似乎是11 天前修复的库中的错误:

There is a regression in Python 3.9 with the find_library() function: Python 3.9 中有一个回归,使用find_library() function:

 >>> 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'

A workaround is to use find_library("c") instead.一种解决方法是改用find_library("c") It also works in older versions of Python and that's already what's used in contrib/isotp.py .它也适用于旧版本的 Python 并且这已经是contrib/isotp.py中使用的内容。

Update scapy since you appear to be using a version of scapy that is incompatible with your version of CPython.更新 scapy,因为您使用的 scapy 版本似乎与您的 CPython 版本不兼容。


Actually, it looks like PyPI hasn't been updated yet, so you won't be able to update through pip .实际上,看起来 PyPI 尚未更新,因此您将无法通过pip进行更新。 You may need to rollback your Python version until it's updated, or manually install the patched scapy version from Github .您可能需要回滚 Python 版本直到它更新,或者从 Github 手动安装修补的 scapy 版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM