# AttributeError: 'module' object has no attribute 'square3\_ff'

**URL:** <https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200>\
**Category:** GNU Radio\
**Created:** [October 29, 2013, 3:45pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200 "2013-10-29T15:45:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [October 29, 2013, 3:45pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200/1 "2013-10-29T15:45:25Z")

</div>

Hello Everyone,

I’m getting an error while adding a new block to grc version  
3.7.2git-110-gb8b9bff2.  
I followed the tutorial at  
[http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules](http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules)

Also had to modify at some points as below.

- in the test code it worked when I changed ;

_from gnuradio import gr, gr\_unittest_ into _from gnuradio import gr,  
gr\_unittest, blocks_

_gr.vector\_source\_f(src\_data)_ into _blocks.vector\_source\_f(src\_data)_

_gr.vector\_sink\_f()_ into _gr.vector\_sink\_f()_

All the tests pass too.  
100% tests passed, 0 tests failed out of 2

I added 3 blocks using c++ for first 2 and python for the last as  
explained  
in the tutorial.  
I can see the blocks in the grc block list and can add them into the  
sketch.  
It generates the python code without any error.  
But the generated python code cannot be run and giving the error below:

Traceback (most recent call last):  
File “top\_block.py”, line 82, in   
tb = top\_block()  
File “top\_block.py”, line 48, in **init**  
self.test\_square3\_ff\_0 = test.square3\_ff()  
AttributeError: ‘module’ object has no attribute ‘square3\_ff’

You can see the generated file from [top\_block.py - Pastebin.com](http://pastebin.com/nE4SFn8Y)

test module is placed under /usr/lib/python2.7/site-packages/test  
gnuradio is under /usr/lib/python2.7/site-packages/gnuradio

Is there any point in the tutorial that does not match with the current  
version of gnuradio?

Thanks in advance

Tarik

* * *

Aydin Tarik Zengin

---

<div class="post-metadata">

**Author:** ![Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/u/Aydin_Tarik_Zengin)\
**Post date:** [October 29, 2013, 4:39pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200/2 "2013-10-29T16:39:10Z")

</div>

Hi Tarik,

On Tue, Oct 29, 2013 at 04:43:53PM +0200, Aydin Tarik Zengin wrote:

> I’m getting an error while adding a new block to grc version  
> 3.7.2git-110-gb8b9bff2.  
> I followed the tutorial at [http://gnuradio.org/redmine/projects/gnuradio/wiki/](http://gnuradio.org/redmine/projects/gnuradio/wiki/)  
> OutOfTreeModules
> 
> Also had to modify at some points as below.
> 
> - in the test code it worked when I changed ;
> 
> from gnuradio import gr, gr\_unittest into from gnuradio import gr, gr\_unittest,  
> blocks

Thanks, there were some references to GNU Radio 3.6-style blocks. I’ve  
updated the tutorial to reflect that.

> All the tests pass too.  
> 100% tests passed, 0 tests failed out of 2

Did you add a test for the Python block? (Perhaps there’s a problem  
in the Python, which would show up here).

> ```
> self.test_square3_ff_0 = test.square3_ff()
> 
> ```
> 
> AttributeError: ‘module’ object has no attribute ‘square3\_ff’
> 
> You can see the generated file from [top\_block.py - Pastebin.com](http://pastebin.com/nE4SFn8Y)
> 
> test module is placed under /usr/lib/python2.7/site-packages/test  
> gnuradio is under /usr/lib/python2.7/site-packages/gnuradio
> 
> Is there any point in the tutorial that does not match with the current version  
> of gnuradio?

Yes there is, but I’m not sure that’s the problem. I couldn’t replicate  
your problem, however.  
Make sure

- your Python block works correctly (unit test it)
- the XML definition for the GRC block is correct
- everything is installed correctly.

Perhaps you want to go over the tutorial with the updated info again.

MB

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association

---

<div class="post-metadata">

**Author:** ![Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/u/Aydin_Tarik_Zengin)\
**Post date:** [November 3, 2013, 3:00pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200/3 "2013-11-03T15:00:31Z")

</div>

Thanks Martin,

Now I’m able to add running blocks.  
However, if I want to add a block written only in Python - there are no  
C++  
files -, I add it with gr\_modtool,

gr\_modtool add -t sync -l python square3\_ff

Then it gives the following error,

You have called ADD\_LIBRARY for library gnuradio-howto without any  
source  
files. This typically indicates a problem with your CMakeLists.txt file  
CMake Error: CMake can not determine linker language for  
target:gnuradio-howto  
CMake Error: Cannot determine link language for target “gnuradio-howto”.

If I add a C++ block with

gr\_modtool add -t general square\_ff

then the error disappears.

What should I do if I want to add a block written only in Python?

And I’m looking for a pure Python block with file-input file-output  
operations?  
Does Gnuradio have such a block as reference?

Thanks in advance,

Tarik

* * *

Aydin Tarik Zengin

---

<div class="post-metadata">

**Author:** ![Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a88e57/32.png) [@Aydin\_Tarik\_Zengin](https://www.ruby-forum.com/u/Aydin_Tarik_Zengin)\
**Post date:** [November 3, 2013, 5:07pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-square3-ff/237200/4 "2013-11-03T17:07:51Z")

</div>

On Sun, Nov 03, 2013 at 03:58:47PM +0200, Aydin Tarik Zengin wrote:

> Now I’m able to add running blocks.

Good 🙂

> CMake Error: Cannot determine link language for target “gnuradio-howto”.  
> The oot-module templates are not designed for not having C++ blocks.  
> The way the CMake templates are set up is that there is at least one C++  
> block.  
> You can always remove the ‘lib’ folder from your module (and the make  
> system); that should work if you only have Python blocks. If this is  
> generally considered a bug, we could add some checks in the CMake files  
> to catch this case.

MB

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association
