python scapy.all 找不到文件
python scapy.all file not found
我试过 运行 我的程序,我试过导入 scapy
然后导入 scapy.all
但是会给我同样的错误。如果有帮助,我正在使用 kali-linux。导致错误的代码仅来自 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"))
到
LIBC = cdll.LoadLibrary(find_library("c"))
这似乎是 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 in
contrib/isotp.py
.
更新 scapy,因为您使用的 scapy 版本似乎与您的 C 版本不兼容Python。
实际上,PyPI 似乎尚未更新,因此您将无法通过 pip
进行更新。您可能需要回滚 Python 版本,直到它更新,或者 manually install the patched scapy version from Github.
我试过 运行 我的程序,我试过导入 scapy
然后导入 scapy.all
但是会给我同样的错误。如果有帮助,我正在使用 kali-linux。导致错误的代码仅来自 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"))
到
LIBC = cdll.LoadLibrary(find_library("c"))
这似乎是 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
.
更新 scapy,因为您使用的 scapy 版本似乎与您的 C 版本不兼容Python。
实际上,PyPI 似乎尚未更新,因此您将无法通过 pip
进行更新。您可能需要回滚 Python 版本,直到它更新,或者 manually install the patched scapy version from Github.