bcc
bcc copied to clipboard
ImportError: cannot import name BPF
4.9.0-8-amd64 #1 SMP Debian 4.9.144-3 (2019-02-02) x86_64 GNU/Linux
After following the installation instructions for Debian here: https://github.com/iovisor/bcc/blob/master/INSTALL.md#debian---source
I am unable to run any of the tools. They all fail with the error message:
from bcc import BPF
ImportError: cannot import name 'BPF'
Here are my current kernel BPF configs:
cat /boot/config-4.9.0-8-amd64 | grep BPF
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# CONFIG_BPF_JIT_ALWAYS_ON is not set
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
CONFIG_TEST_BPF=m
Any help would be appreciated.
I also encounter this same issue on Ubuntu 18.04 when using the installed tools..
bwalker@brads-T460s:~$ apt list --installed | grep bpfcc-tools
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
bpfcc-tools/bionic,bionic,now 0.5.0-5ubuntu1 all [installed]
bwalker@brads-T460s:~$ /usr/sbin/biolatency-bpfcc
Traceback (most recent call last):
File "/usr/sbin/biolatency-bpfcc", line 15, in <module>
from bcc import BPF
ImportError: cannot import name BPF
bwalker@brads-T460s:~$
You need to install python-bcc or python3-bcc
I am still getting this issue
I also encounter this same issue on centos8 when using the installed python3-bcc
dnf list --installed bcc.x86_64 0.11.0-2.el8 @AppStream
bcc-tools.x86_64 0.11.0-2.el8 @AppStream
python3-bcc.x86_64 0.11.0-2.el8 @AppStream
Try running it with 'sudo su' -
I had this problem but managed to make it disappear with pip3 uninstall bcc
python2.7 ok python3 unsuccessful
Look at Install.md file. You may need to build bcc with PYTHON_CMD option like
cmake .. -DPYTHON_CMD=python3 # for python3 support
FWIW - in my case it turns out that sudo /bin/python3 /usr/share/bcc/tools/execsnoop
works.
python3 resolves (as per $PATH) to ~/.pyenv/shims/python3 in my case - it is 3.8.8 .. same as /usr/bin/python, needed for https://github.com/elastic/rally
/bin/python3 is the "system's" i.e. CentOS 8.3 distribution's 3.6.8
use 'apt install python3-bpfcc ' , 'pip3 install bcc' not works
use 'apt install python3-bpfcc ' , 'pip3 install bcc' not works
I tried on AlmaLinux9. worked: 'sudo yum install python3-bcc ' not worked: 'pip3 install bcc'
I also had this problem using python3.9. When I exec "yum install python3", it will install python3.6,it won't this problem.
I met a similar issue:
Traceback (most recent call last):
File "/path/of/bitehist.py", line 17, in <module>
from bcc import BPF
ImportError: cannot import name 'BPF' from 'bcc' (/opt/python/3.9.6/lib/python3.9/site-packages/bcc/__init__.py)
And I fixed it with:
export PYTHONPATH=$(dirname `find /usr/lib -name bcc`):$PYTHONPATH
The fix is from: https://github.com/iovisor/bcc/blob/master/FAQ.txt#L17
I met a similar issue:
Traceback (most recent call last): File "/path/of/bitehist.py", line 17, in <module> from bcc import BPF ImportError: cannot import name 'BPF' from 'bcc' (/opt/python/3.9.6/lib/python3.9/site-packages/bcc/__init__.py)
And I fixed it with:
export PYTHONPATH=$(dirname `find /usr/lib -name bcc`):$PYTHONPATH
The fix is from: https://github.com/iovisor/bcc/blob/master/FAQ.txt#L17
Thanks a lot @pangle-zhang ! That's the only one that made it worked! Thank you so much!