简体   繁体   English

尝试执行 ./uhd_fft 时出现“ImportError no module named gnuradio”

[英]“ImportError no module named gnuradio” when trying to execute ./uhd_fft

I have followed instructions out lined here:我已按照此处列出的说明进行操作:

http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804 http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804

and installed GNU Radio from GIT repo (scroll down to the section that says "Building GNURADIO from GIT". I used the ./build-gnuradio.sh script to do this and it took a while, but it appeared to build successfully, as per the instructions.并从 GIT 存储库安装了 GNU Radio(向下滚动到“从 GIT 构建 GNURADIO”部分。我使用 ./build-gnuradio.sh 脚本来做到这一点,这花了一段时间,但它似乎成功构建,如根据说明。

I am running on Ubuntu 12.04 LTS.我在 Ubuntu 12.04 LTS 上运行。

When I attempt to run the "./uhd_fft" function I get the following error message:当我尝试运行“./uhd_fft”函数时,我收到以下错误消息:

Traceback (most recent call last):
  File "./uhd_fft", line 23, in <module>
    from gnuradio import gr, gru
ImportError: No module named gnuradio

I have Googled this error message and most of the forums claim there is a problem with the PYTHONPATH.我在谷歌上搜索了这条错误消息,大多数论坛都声称 PYTHONPATH 有问题。

When I do当我做

echo $PYTHONPATH
/usr/bin/python2.7

But when I check the python2.7 directory I do not see gnuradio.但是当我检查 python2.7 目录时,我没有看到 gnuradio。 So I guess it makes sense I'm getting an import error when it tries to import gnuradio.所以我想我在尝试导入 gnuradio 时遇到导入错误是有道理的。 But the bigger question is why?但更大的问题是为什么?

I installed GNU Radio (per instructions from nuand forum) using ./build-gnuradio.sh script.我使用 ./build-gnuradio.sh 脚本安装了 GNU Radio(根据 nuand 论坛的说明)。 So I should have it installed.所以我应该安装它。

I would appreciate if it python / GNU Radio experts from the community could weigh in.如果来自社区的 python / GNU Radio 专家能够参与进来,我将不胜感激。

There is a section later in the instructions with this boldface label:说明中有一个部分带有此粗体标签:

Now for some voodoo to get the new program installed into system libraries and python paths and executable path.现在让一些伏都教将新程序安装到系统库和 python 路径和可执行路径中。

Those instructions lead you through modifying your PYTHONPATH to pick up the gnuradio module, among other things.这些说明会引导您修改 PYTHONPATH 以获取 gnuradio 模块等。 If you have followed those instructions, you will have to start a new shell to see any effect, or execute the .sh file by hand, since profile scripts only run when a new shell starts up or when they're run manually.如果您遵循了这些说明,则必须启动一个新的 shell 才能看到任何效果,或者手动执行 .sh 文件,因为配置文件脚本仅在新的 shell 启动或手动运行时运行。

One of the reason for this error is, when the default python is selected incorrectly.出现此错误的原因之一是,错误地选择了默认的 python。 To see which python is selected type the following command in the Terminal:要查看选择了哪个 python,请在终端中键入以下命令:

      "sudo port select python"

it will display all the python available on your mac.它将显示您的 mac 上可用的所有 python。 like:像:

    python26

    python27-apple(Active)

    python27

For Gnuradio you need python27,if other python is active like in the example above you can change it by the following command:对于 Gnuradio,你需要 python27,如果其他 python 像上面的例子一样处于活动状态,你可以通过以下命令更改它:

    "sudo port select python python27" 

Now RUN your python code,it should work.If python27 is already active you may consider changing the path manually as suggested by others现在运行你的python代码,它应该可以工作。如果python27已经激活,你可以考虑按照其他人的建议手动更改路径

一旦设置了 PATH 变量,就试试这个。

ln -sf /usr/lib/x86_64-linux-gnu/libvolk.so.1.3.1 /usr/lib/x86_64-linux-gnu/libvolk.so.1.3

On OSX 10.12.3 (16D32) this worked for me:在 OSX 10.12.3 (16D32) 上,这对我有用

export PATH=/opt/local/bin:$PATH

python
> import gnuradio

For me python at the prompt was using Mac's python instead of the one in /opt/local/bin/python对我来说,提示处的 python 是使用 Mac 的 python 而不是 /opt/local/bin/python 中的 python

The link you have provided also mentioned that you might need to add dist-packages and site-packages .您提供的链接还提到您可能需要添加dist-packagessite-packages

The following command solved the issue for me:以下命令为我解决了这个问题:

export export PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3.6/dist-packages:\
/usr/local/lib/python3/site-packages:/usr/local/lib/python3.6/site-packages:$PYTHONPATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ImportError:没有名为“ gnuradio”的模块 - ImportError: No module named 'gnuradio' 尝试在 Windows 中使用 gnuradio/uhd 时出现 Python 错误 - Python error when trying to use gnuradio/uhd in Windows Python 错误:ImportError:没有名为 FFT 的模块 - Python Error: ImportError: No module named FFT ModuleNotFoundError:没有名为“gnuradio”的模块 - ModuleNotFoundError : No module named 'gnuradio' ImportError:当模块在那里时,没有模块被命名 - ImportError: No module named when module is there 导入错误:尝试导入祝福时没有名为“_curses”的模块 - ImportError: No module named '_curses' when trying to import blessings 尝试将 pyx 文件导入 Jupyter 时出现“ImportError: No module named ...” - 'ImportError: No module named ...' when trying to import pyx file to Jupyter 尝试运行 Python 脚本时出现“ImportError: No module named” - "ImportError: No module named" when trying to run Python script ImportError:尝试安装 package 时没有名为“typing”的模块 - ImportError: No module named 'typing' when trying to install a package 尝试导入pylab时出现“ ImportError:没有名为pytz的模块”? - 'ImportError: No module named pytz' when trying to import pylab?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM