程式語言 - Python - 解決cannot import name BPF from bcc問題



參考資訊:
https://github.com/iovisor/bcc/issues/2278

問題如下:

# python3 ./run.py 
    Traceback (most recent call last):
      File "/home/steward/Downloads/./run.py", line 9, in 
        from bcc import BPF
    ImportError: cannot import name 'BPF' from 'bcc' (/home/steward/.local/lib/python3.11/site-packages/bcc/__init__.py)

解法如下:

# export PYTHONPATH=$(dirname `find /usr/lib -name bcc`):$PYTHONPATH
# python3 ./run.py