1

从源代码构建 BCC 并运行测试“sudo /usr/share/bcc/tools/execsnoop”后,我得到以下输出:

回溯(最后一次调用):文件“/usr/share/bcc/tools/execsnoop”,第 21 行,in from bcc import BPF ImportError: No module named bcc

这是什么意思,可以采取什么措施来补救?

安装依赖项后,这些是我遵循的步骤:

git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
# python2 can be substituted here, depending on your environment
cmake -DPYTHON_CMD=python3 ..
make && sudo make install

sudo /usr/share/bcc/tools/execsnoop #Test
4

1 回答 1

0

这是由于将 python2 设置为默认 python 造成的。

$ ls -l `which python`
lrwxrwxrwx 1 root root 7 Mar  4  2019 /usr/bin/python -> python2

有一种方法可以改变所有出现的

#!/usr/bin/python#!/usr/bin/python3

或者

sudo ln -s /usr/bin/python3 /usr/bin/python

或者

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 100
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode

这会将python更改为替代python

$ ls -l `which python`
lrwxrwxrwx 1 root root 24 Nov 29 20:21 /usr/bin/python -> /etc/alternatives/python
于 2020-11-29T14:53:21.267 回答