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
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:
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.