问题
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. I am using kali-linux if that helps. The code that is causing the error is just from scapy.all import *
This is the full error 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:
/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"))
回答1:
This appears to have been a bug in the library that was fixed 11 days ago:
There is a regression in Python 3.9 with the
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. It also works in older versions of Python and that's already what's used incontrib/isotp.py.
Update scapy since you appear to be using a version of scapy that is incompatible with your version of CPython.
Actually, it looks like PyPI hasn't been updated yet, so you won't be able to update through pip. You may need to rollback your Python version until it's updated, or manually install the patched scapy version from Github.
来源:https://stackoverflow.com/questions/65410697/python-scapy-all-file-not-found