0

I installed successfully GNU Radio in Ubuntu 14.04. I tested the installing and it returned 100% passed. However, when I run it with python code. It returned the error such as

File "/home/gnuradio-3.7.5/gr-digital/examples/narrowband/uhd_interface.py", line 23, in <module>
from gnuradio import gr, uhd
ImportError: cannot import name uhd

What is my error? Could you help me to solve it? Thanks

My import is

from gnuradio import *
from gnuradio import gr, digital
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser

# from current dir
from receive_path  import receive_path
from transmit_path import transmit_path
from uhd_interface import uhd_transmitter
from uhd_interface import uhd_receiver
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Jame
  • 3,746
  • 6
  • 52
  • 101

2 Answers2

1

Have you tried from gnuradio import* or import gnuradio? If that doesn't work, then you have to manually check it in gnuradio's library if such function exists. Also check if you've installed the right version for python 2.7

Eninfo
  • 217
  • 1
  • 2
  • 11
  • Perhaps have a read on this https://lists.gnu.org/archive/html/discuss-gnuradio/2011-07/msg00199.html – Eninfo Oct 23 '15 at 07:38
1

This is probably the case because your GNU Radio was built without UHD support, so the gr-uhd component is not available.

This is a obstacle frequently encountered, so I have a "surefire" method:

  • uninstall all possibly broken versions of GNU Radio and UHD
  • install them cleanly from source

Her's how to go about:

/home/gnuradio-3.7.5/gr-digital/examples/narrowband/uhd_interface.py

Judging from your path, you're building GNU Radio yourself, from hand. By the way, this is a terrible path; /home/ is reserved for user home directories, and there should be no user called gnuradio-3.7.5, as usernames with . are asking for trouble.

So

cd /home/gnuradio-3.7.5/build
sudo make uninstall

should remove anything that was built from source.

Then, make sure that there's no conflicting Ubuntu installation

sudo apt-get remove gnuradio uhd-host libuhd003

Afterwards, use pybombs to install everything:

#assuming you have git installed:
git clone --recursive git://github.com/pybombs/pybombs
cd pybombs
./pybombs install gnuradio uhd

That will ask you a few questions, among those a prefix directory in which pybombs will install GNU Radio and everything necessary that Ubuntu itself doesn't ship. I recommend leaving it to the default value (just press enter) and then, after pybombs finished downloading, building and installing everything, run

./pybombs env
echo "source {directory that everything got installed to}/setup_env.sh" >> ~/.bashrc

Then, you've got a nice, recent GNU Radio installation that contains gr-uhd. Notice that you must not install gnuradio or uhd from Ubuntu; Ubuntu's UHD version is so old that it doesn't support any of the current USRP series.


If after successful software installation you still get errors that GNU Radio can't find the USRP device, see this Q&A.

Community
  • 1
  • 1
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • Thanks, I solved it by reinstall GNUradio. However, I tried to run it but it appeared a new error that is "RuntimeError: LookupError: KeyError: No devices found for -----> Empty Device Address". I add ip address in the uhd_interface.py file as uhd.usrp_source(device_addr="addr=192.168.10.2" but it still error "RuntimeError: LookupError: KeyError: No devices found for -----> Device Address: addr: 192.168.10.2" I think I will post a new question. If you know it, please help me. – Jame Oct 23 '15 at 13:16
  • Muller: I posed it at http://stackoverflow.com/questions/33303623/runtimeerror-lookuperror-keyerror-no-devices-found-in-gnuradio-in-unbutu – Jame Oct 23 '15 at 13:32
  • You just told us there you wanted to **simulate**, yet you're using a flowgraph that **wants to talk to hardware**. If you want to *simulate*, you don't have to buy hardware--just use a GNU Radio program that is not something that wants to talk to *real* hardware. You also asked for "Famous Board Name": all the USRPs work with GNU Radio's `gr-uhd`, and [Ettus](http://www.ettus.com/) (and its mother company, National Instruments) is the only company that produces the USRPs. When you modify the program,you might also use different hardware. Again,you haven't even told us what you're trying to do – Marcus Müller Oct 23 '15 at 14:31
  • I am trying to simulate channel coding. In which, the sender will encode a video and send to decoder. As the link which I sent to you, he encoded video at sender side and decode it at receiver side. I am trying to do it. I build the channel coding method successfully. Now, I want to use Gnuradio to run as his simulation – Jame Oct 24 '15 at 01:13