# OOT Python Block

**URL:** <https://www.ruby-forum.com/t/oot-python-block/234004>\
**Category:** GNU Radio\
**Created:** [January 29, 2015, 11:22pm UTC](https://www.ruby-forum.com/t/oot-python-block/234004 "2015-01-29T23:22:59Z")\
**Posts on this page:** 7\
**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:** [January 29, 2015, 11:22pm UTC](https://www.ruby-forum.com/t/oot-python-block/234004/1 "2015-01-29T23:22:59Z")

</div>

I’ve created a python block that I’ve tested via command line. It passes  
all qa tests. I’ve also created an xml file for it and installed it. I  
followed every step the OOT Python Tutorial explains.

I see the category and block in gnuradio-companion. When I use my block  
in  
a flowgraph, upon to executing the graph I get

_AttirbuteError: ‘module’ object has no attribute  
‘\<my\_module\_name\_here\>’_

I’ve added the block build location to the PYTHONPATH variable and  
confirmed that I can import my module at a python command line.

What do I not have set correctly and what is this error telling me?

Thanks,  
Rich

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 30, 2015, 8:04am UTC](https://www.ruby-forum.com/t/oot-python-block/234004/2 "2015-01-30T08:04:56Z")

</div>

Hi Richard,

I noticed the same problem with some blocks in my own OOT module. I do  
not know why, but if you change the lines in the GRC file to (if not  
already done)  
 import my\_module.my\_block\_name\_here  
my\_module.my\_block\_name\_here.my\_block\_name\_here(…)

(note the double block\_name in )

I do not remember right, but it might also be sufficient to change only  
either one of the lines (you have to try on your own).  
You can try by calling the from python. E.g. IPython has tab completion  
and you can see by import my\_module. (and so on for the make  
line), what block is how accessible.

Regards Stephan

Mit freundlichen Grüßen / Best regards

Stephan Ludwig

Robert Bosch GmbH  
Corporate Sector Research & Advance Engineering, Communication  
Technology (CR/AEH4)  
Renningen  
70465 Stuttgart  
GERMANY  
[www.bosch.com](http://www.bosch.com)[http://www.bosch.com](http://www.bosch.com)

Tel. +49(711)811-8809  
Fax +49(711)811-1052  
Mobile +49(172)5630639  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Registered Office: Stuttgart, Registration Court: Amtsgericht Stuttgart,  
HRB 14000;  
Chairman of the Supervisory Board: Franz Fehrenbach; Managing Directors:  
Dr. Volkmar Denner,  
Dr. Stefan Asenkerschbaumer, Dr. Rolf Bulander, Dr. Stefan Hartung, Dr.  
Dirk Hoheisel, Christoph Kübel,  
Uwe Raschke, Wolf-Henning Scheider, Dr. Werner Struth, Peter Tyroller  
Von: discuss-gnuradio-bounces+stephan.ludwig2=removed\_email\_address@domain.invalid  
[[mailto:discuss-gnuradio-bounces+stephan.ludwig2=removed\_email\_address@domain.invalid](mailto:discuss-gnuradio-bounces+stephan.ludwig2=removed_email_address@domain.invalid)]  
Im Auftrag von Richard B.  
Gesendet: Donnerstag, 29. Januar 2015 23:22  
An: removed\_email\_address@domain.invalid  
Betreff: [Discuss-gnuradio] OOT Python Block

I’ve created a python block that I’ve tested via command line. It passes  
all qa tests. I’ve also created an xml file for it and installed it. I  
followed every step the OOT Python Tutorial explains.

I see the category and block in gnuradio-companion. When I use my block  
in a flowgraph, upon to executing the graph I get

AttirbuteError: ‘module’ object has no attribute ‘\<my\_module\_name\_here\>’

I’ve added the block build location to the PYTHONPATH variable and  
confirmed that I can import my module at a python command line.

What do I not have set correctly and what is this error telling me?

Thanks,  
Rich

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 31, 2015, 4:42am UTC](https://www.ruby-forum.com/t/oot-python-block/234004/3 "2015-01-31T04:42:56Z")

</div>

On Fri, Jan 30, 2015 at 5:31 AM, Ludwig Stephan (CR/AEH4) \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> Regards
> 
> Stephan

Ahh! Thanks for pointing that out. I had missed the fact that it was a  
Python block (and I rarely work with them myself).

Ok, I think the fix for that is to add a “from x import \*” into the  
**init**.py file for the module where x is your Python block. We should  
test this and add it to gr\_modtool to avoid this confusion in the  
future.

Tom

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 31, 2015, 10:51am UTC](https://www.ruby-forum.com/t/oot-python-block/234004/4 "2015-01-31T10:51:06Z")

</div>

Here is what my _ **init**.py_ looked like prior to changes:

_try:_

- from test\_swig import \*\*  
_except ImportError:_
- pass\*

\*from qpsk\_demod\_py\_cb import qpsk\_demod\_py\_cb \* \<— my block

And after the adding the change you suggested:

_try:_

- from test\_swig import \*\*  
_except ImportError:_
- pass\*

\*from qpsk\_demod\_py\_cb import \*\*

After running make again, installing and sudo ldconfig, this has not  
fixed  
the AttributeError I see in gnuradio-companion.

Rich

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 30, 2015, 9:47am UTC](https://www.ruby-forum.com/t/oot-python-block/234004/5 "2015-01-30T09:47:26Z")

</div>

On Fri, Jan 30, 2015 at 2:03 AM, Ludwig Stephan (CR/AEH4) \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> my\_module.my\_block\_name\_here.my\_block\_name\_here(…)  
> You can try by calling the from python. E.g. IPython has tab completion  
> and you can see by import my\_module. (and so on for the make line),  
> what block is how accessible.
> 
> Regards Stephan

That can’t be right. You really shouldn’t have to do that to get the  
block  
to work.

We periodically get this bug from our users, no one has ever explained  
how  
to reproduce it, and I’ve never seen this failure mode myself. As long  
as  
you used gr\_modtool and made the necessary changes to the files – which  
really just means fixing the \<+…+\> in the impl.cc file – then it  
should  
just “work”.

Tom

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 31, 2015, 6:29pm UTC](https://www.ruby-forum.com/t/oot-python-block/234004/6 "2015-01-31T18:29:28Z")

</div>

Unfortunately that didn’t work either.

Anyone out there making custom python blocks who worked through this  
AttributeError? Is it just a few of us seeing the error?

v/r,  
Rich

On Fri, Jan 30, 2015 at 3:23 PM, Richard B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [January 31, 2015, 5:28pm UTC](https://www.ruby-forum.com/t/oot-python-block/234004/7 "2015-01-31T17:28:18Z")

</div>

Stephan,

Just to be sure I attempt your solution correctly, you mean to have me  
double the block\_name in the xml file that exists in the gr\_modtool  
created  
grc directory, is that right?

v/r,  
Rich

On Fri, Jan 30, 2015 at 8:47 AM, Richard B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
