Hi. I was trying to install on Kali Linux 2020.2 and ran the install as suggested.
sudo apt install python3-pip && pip3 install Cython && pip3 install python-libpcap
However, I was getting the following error I included below.
I was able to solve by installing libpcap-dev.
sudo apt install libpcap-dev
FYI in case others run into the issue.
Building wheel for python-libpcap (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"'; file='"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-l7d1cm3m
cwd: /tmp/pip-install-mg382xue/python-libpcap/
Complete output (34 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/utils.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/command.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/pcap.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/main.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/open.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/init.py -> build/lib.linux-x86_64-3.8/pylibpcap
running egg_info
writing python_libpcap.egg-info/PKG-INFO
writing dependency_links to python_libpcap.egg-info/dependency_links.txt
writing entry points to python_libpcap.egg-info/entry_points.txt
writing requirements to python_libpcap.egg-info/requires.txt
writing top-level names to python_libpcap.egg-info/top_level.txt
reading manifest file 'python_libpcap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '.h' under directory 'src'
warning: no previously-included files matching '.pyc' found anywhere in distribution
writing manifest file 'python_libpcap.egg-info/SOURCES.txt'
copying pylibpcap/base.c -> build/lib.linux-x86_64-3.8/pylibpcap
running build_ext
building 'pylibpcap.base' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/pylibpcap
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c pylibpcap/base.c -o build/temp.linux-x86_64-3.8/pylibpcap/base.o -lpcap
pylibpcap/base.c:622:10: fatal error: pcap.h: No such file or directory
622 | #include "pcap.h"
| ^~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
ERROR: Failed building wheel for python-libpcap
Running setup.py install for python-libpcap ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"'; file='"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-ua36ifxi/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/python-libpcap
cwd: /tmp/pip-install-mg382xue/python-libpcap/
Complete output (34 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/utils.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/command.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/pcap.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/main.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/open.py -> build/lib.linux-x86_64-3.8/pylibpcap
copying pylibpcap/init.py -> build/lib.linux-x86_64-3.8/pylibpcap
running egg_info
writing python_libpcap.egg-info/PKG-INFO
writing dependency_links to python_libpcap.egg-info/dependency_links.txt
writing entry points to python_libpcap.egg-info/entry_points.txt
writing requirements to python_libpcap.egg-info/requires.txt
writing top-level names to python_libpcap.egg-info/top_level.txt
reading manifest file 'python_libpcap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '.h' under directory 'src'
warning: no previously-included files matching '.pyc' found anywhere in distribution
writing manifest file 'python_libpcap.egg-info/SOURCES.txt'
copying pylibpcap/base.c -> build/lib.linux-x86_64-3.8/pylibpcap
running build_ext
building 'pylibpcap.base' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/pylibpcap
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c pylibpcap/base.c -o build/temp.linux-x86_64-3.8/pylibpcap/base.o -lpcap
pylibpcap/base.c:622:10: fatal error: pcap.h: No such file or directory
622 | #include "pcap.h"
| ^~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"'; file='"'"'/tmp/pip-install-mg382xue/python-libpcap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-ua36ifxi/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/python-libpcap Check the logs for full command output.