Search code examples
bpfebpfbcc-bpf

bcc: ImportError cannot import name BPF


I am getting the following error when trying run the example hello_world.py.

Traceback (most recent call last):
  File "/usr/share/bcc/examples/hello_world.py", line 9, in <module>
    from bcc import BPF
ImportError: cannot import name BPF

I installed bcc from source (link). I also installed both the python bcc bindings packages, python-bcc and python3-bcc but no luck.

I am running Ubuntu 18.04 and kernel version 4.15.0-117-generic.

What am I missing here?


Solution

  • I got the issue. I was using the pyenv to manage my python versions, so the python was looking files in the wrong locations.

    $ python -c 'import site; print(site.getsitepackages())'
    ['/home/sagar/.pyenv/versions/3.6.6/lib/python3.6/site-packages']
    

    I tried with a python3 command, which was not installed by pyenv and I don't get the above error.