# ImportError: cannot import name blks2

**URL:** <https://www.ruby-forum.com/t/importerror-cannot-import-name-blks2/234790>\
**Category:** GNU Radio\
**Created:** [July 2, 2014, 10:05pm UTC](https://www.ruby-forum.com/t/importerror-cannot-import-name-blks2/234790 "2014-07-02T22:05:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 2, 2014, 10:05pm UTC](https://www.ruby-forum.com/t/importerror-cannot-import-name-blks2/234790/1 "2014-07-02T22:05:36Z")

</div>

Somewhat a NOOB to Python, USRP, GNURadio… and needing some help.

I am getting the error (below) when I try to execute a Python xxx.py  
progam…  
ImportError: cannot import name blks2

Here is what I am trying to do. I am trying to run an installed OSMOCOM  
radio program xxx.py

With examination… in the OSMOCOM xxx.py file… line #17 is trying to  
import a number of GNUradio and Python packages.

Line #17 looks like:  
from gnuradio import gr, gru, eng\_notation, blks2, optfir

I am running Ubuntu 14.04…  
I have done the following…

1. Installed the latest 3.7x GNUradio package
2. I want to run with a N210 USRP SDR… Installed the UHD driver from  
[Ettus.com](http://Ettus.com)  
([http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki](http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki))
3. Downloaded OSMOCOM code and built it from GitHub.

After a while of Googling for answers… I have wound up here to post  
for help.

From previous threads out on the internet, I feel like I just have a  
Python import problem… and really not a GNUradio, OSMOCOM, or USRP  
problem. So I am not going to go list specifics at this time on the  
\*\*\*.py file and GNUradio specifiics…

From other threads my guess is that the problem lies in that I was  
missing a $PYTHONPATH env variable.

The BLKS2 module is located in my  
/usr/lib/python2.7/dist-packages/grc\_gnuradio directory.

I tried adding this $PYTHONPATH env variable, and to point to the  
specific directory… but the error still occurs.

I do have other Python versions on the Linux machine, but no other env  
variable points to another version of Python.

Would I have a Python install problem? However it is a fresh load of  
Ubuntu… so I would think this would have installed correctly in the  
default load of the OS.

Should my $PYTHONPATH env variable contain more paths that just:

```
PYTHONPATH=/usr/lib/python2.7/dist-packages
                  or
PYTHONPATH=/usr/lib/python2.7/dist-packages/grc_gnuradio/blks2

```

Any help would be greatly appreciated!! Thanks in advance.

-kenhokie

---

<div class="post-metadata">

**Author:** ![kscott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7993a0/32.png) [@kscott](https://www.ruby-forum.com/u/kscott)\
**Post date:** [August 25, 2014, 4:05pm UTC](https://www.ruby-forum.com/t/importerror-cannot-import-name-blks2/234790/2 "2014-08-25T16:05:13Z")

</div>

Hi Ken,

It looks as though your message went down a black hole because it was  
sent via the [ruby-forum.com](http://ruby-forum.com) website and not the GNU Radio mailing list  
at [http://gnuradio.org/redmine/projects/gnuradio/wiki/MailingLists](http://gnuradio.org/redmine/projects/gnuradio/wiki/MailingLists) .

The message is not in the official GNU Radio mailing list archive so was  
never sent to the actual list:

> **[discuss-gnuradio (date)](https://lists.gnu.org/archive/html/discuss-gnuradio/2014-07/index.html)**

I came across your post as I was getting the same error as you and  
Googled it. I have just modified uhd-tetra\_demod.py and cqpsk.py to  
make the uhd version work and the commit is available in the branch  
called ‘gr\_3.7.4\_compatibility’:

[https://github.com/m0mik/osmo-tetra/tree/gr\_3.7.4\_compatibility](https://github.com/m0mik/osmo-tetra/tree/gr_3.7.4_compatibility)

List of files changed:

[https://github.com/m0mik/osmo-tetra/commit/5429a1e3abf3e5c1aeadc0253169233faee46cc8](https://github.com/m0mik/osmo-tetra/commit/5429a1e3abf3e5c1aeadc0253169233faee46cc8)

Mike

Ken Smith wrote in post #1151491:

> Somewhat a NOOB to Python, USRP, GNURadio… and needing some help.
> 
> I am getting the error (below) when I try to execute a Python xxx.py  
> progam…  
> ImportError: cannot import name blks2
> 
> Here is what I am trying to do. I am trying to run an installed OSMOCOM  
> radio program xxx.py
> 
> With examination… in the OSMOCOM xxx.py file… line #17 is trying to  
> import a number of GNUradio and Python packages.
> 
> Line #17 looks like:  
> from gnuradio import gr, gru, eng\_notation, blks2, optfir
> 
> I am running Ubuntu 14.04…  
> I have done the following…
> 
> 1. Installed the latest 3.7x GNUradio package
> 2. I want to run with a N210 USRP SDR.. Installed the UHD driver from  
> [Ettus.com](http://Ettus.com)  
> ([http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki](http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki))
> 3. Downloaded OSMOCOM code and built it from GitHub.
> 
> After a while of Googling for answers… I have wound up here to post  
> for help.
> 
> From previous threads out on the internet, I feel like I just have a  
> Python import problem… and really not a GNUradio, OSMOCOM, or USRP  
> problem. So I am not going to go list specifics at this time on the  
> \*\*\*.py file and GNUradio specifiics…
> 
> From other threads my guess is that the problem lies in that I was  
> missing a $PYTHONPATH env variable.
> 
> The BLKS2 module is located in my  
> /usr/lib/python2.7/dist-packages/grc\_gnuradio directory.
> 
> I tried adding this $PYTHONPATH env variable, and to point to the  
> specific directory… but the error still occurs.
> 
> I do have other Python versions on the Linux machine, but no other env  
> variable points to another version of Python.
> 
> Would I have a Python install problem? However it is a fresh load of  
> Ubuntu.. so I would think this would have installed correctly in the  
> default load of the OS.
> 
> Should my $PYTHONPATH env variable contain more paths that just:
> 
> ```
> PYTHONPATH=/usr/lib/python2.7/dist-packages
> or
> PYTHONPATH=/usr/lib/python2.7/dist-packages/grc_gnuradio/blks2
> 
> ```
> 
> Any help would be greatly appreciated!! Thanks in advance.
> 
> -kenhokie
