找不到 python scapy.all 文件 [英] python scapy.all file not found
问题描述
我试过运行我的程序,我试过 import scapy
然后 import scapy.all
但它会给我同样的错误.如果有帮助,我正在使用 kali-linux.导致错误的代码来自 scapy.all import *
这是完整的错误输出:
回溯(最近一次调用最后一次):文件/home/bradz/test.py",第 24 行,在 <module> 中.from scapy.all 导入发送、IP、TCP、ARP文件/usr/local/lib/python3.9/dist-packages/scapy/all.py",第16行,在<module>从 scapy.arch 导入 *文件/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py",第27行,在<module>从 scapy.arch.bpf.core 导入 get_if_raw_addr
文件/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py",第30行,在<module>LIBC = cdll.LoadLibrary(find_library(libc"))find_library 中的文件/usr/lib/python3.9/ctypes/util.py",第 341 行_get_soname(_findLib_gcc(name)) 或 _get_soname(_findLib_ld(name))_findLib_gcc 中的文件/usr/lib/python3.9/ctypes/util.py",第 147 行如果不是 _is_elf(file):文件/usr/lib/python3.9/ctypes/util.py",第 99 行,在 _is_elf以 open(filename, 'br') 作为文件:FileNotFoundError: [Errno 2] 没有那个文件或目录: 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"))
这似乎是库中的一个错误 11 天前修复:
<块引用>find_library()
在 Python 3.9 中有一个回归功能:
一种解决方法是使用 find_library("c")
代替.它也适用于旧版本的 Python 已经在使用了contrib/isotp.py
.
更新 scapy,因为您使用的 scapy 版本似乎与您的 CPython 版本不兼容.
实际上,PyPI 似乎还没有更新,因此您将无法通过 pip
进行更新.你可能需要回滚你的 Python 版本直到它更新,或者 手动从 Github 安装打补丁的 scapy 版本.
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"))
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.
这篇关于找不到 python scapy.all 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!