安装后 GNU Radio 上的 ModuleNotFoundError

ModuleNotFoundError on GNU Radio right after installation

我正尝试按照官方说明在我的 Ubuntu 19.10 上手动安装 GNU Radio(https://wiki.gnuradio.org/index.php/InstallingGR)

当我尝试 运行 GNU Radio 时,弹出此错误:

Is the python path environment variable set correctly? All OS: PYTHONPATH

Is the library path environment variable set correctly? Linux: LD_LIBRARY_PATH Windows: PATH MacOSX: DYLD_LIBRARY_PATH

No module named 'gnuradio'

我在 Whosebug 上查看了关于此问题的类似帖子,但仍然无法解决。

如何根据以下当前参数正确设置变量?

galib@galib-Lenovo-Y50-70:~$ python --version

Python 3.7.5


galib@galib-Lenovo-Y50-70:~$ echo $PYTHONPATH

:/lib/python3.7/dist-packages


galib@galib-Lenovo-Y50-70:~$ echo $LD_LIBRARY_PATH

/opt/qt/lib:/usr/local/lib::/home/galib/miniconda3/envs/dsp/lib


galib@galib-Lenovo-Y50-70:~$ which python

/usr/bin/python


galib@galib-Lenovo-Y50-70:~$ gnuradio-config-info -v
3.8.1.0
galib@galib-Lenovo-Y50-70:~$ gnuradio-config-info --prefix
/usr/local


galib@galib-Lenovo-Y50-70:~$ find /usr/local -name gnuradio | grep "packages"
/usr/local/lib/python3/dist-packages/gnuradio


galib@galib-Lenovo-Y50-70:~$ whereis python

python: /usr/bin/python3.7 /usr/bin/python3.7-config /usr/bin/python /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python3.7m-config /usr/bin/python3.7m /usr/lib/python3.7 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib/python2.7 /etc/python3.7 /etc/python /etc/python2.7 /usr/local/lib/python3.7 /usr/local/lib/python2.7 /usr/include/python3.7 /usr/include/python2.7 /usr/include/python3.7m /usr/share/python /usr/share/man/man1/python.1.gz
galib@galib-Lenovo-Y50-70:~$ find /usr/local -name gnuradio | grep "packages"
/usr/local/lib/python3/dist-packages/gnuradio

您需要将 /usr/local/lib/python3/dist-packages 添加到 PYTHONPATH 环境变量,因为此目录不在默认的 python 搜索路径中 (sys.path)

打开一个新终端并执行以下命令

export PYTHONPATH=/usr/local/lib/python3/dist-packages:$PYTHONPATH
gnuradio-companion

要使此更改永久生效,您可以将导出行添加到 ~/.profile 文件中。另见 Module Not Found Error