# AttributeError: 'module' object has no attribute 'block\_name'

**URL:** <https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864>\
**Category:** GNU Radio\
**Created:** [September 3, 2014, 3:18pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864 "2014-09-03T15:18:41Z")\
**Posts on this page:** 5\
**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:** [September 3, 2014, 3:18pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864/1 "2014-09-03T15:18:41Z")

</div>

Hi,  
I created a C++ block with gr\_modtool,  
following the commands:

$ gr\_modtool newmod PWagc  
$ gr\_modtool add -t general power\_control

I written and compiled my block with commands:

$cmake …/ && make && sudo make install && sudo ldconfig

Until this point all seems ok, but when I open gnuradio and try to  
simulate  
my block…  
the following error appears:

Traceback (most recent call last):  
File “/home/simone/Scrivania/top\_block.py”, line 261, in   
tb = top\_block(address=options.address)  
File “/home/simone/Scrivania/top\_block.py”, line 153, in **init**  
self.PWagc\_power\_control\_0 = PWagc.power\_control(0.001, 0.25)  
AttributeError: ‘module’ object has no attribute ‘power\_control’

I’m not able to understand from which this error derive…  
If needed, I can attach the \_impl.cc etc… files.

My gnuradio version is the 3.7.4 and  
PYTHONPATH=/usr/local/lib/python2.7/dist-packages,  
in this last folder I can see the installed gr-PWagc directory.

Someone can help me please?  
If additional information are needed, please ask me… I’m blocked here!

Thanks,  
Simone Ciccia

---

<div class="post-metadata">

**Author:** ![Simone\_Ciccia\_S2106](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Simone\_Ciccia\_S2106](https://www.ruby-forum.com/u/Simone_Ciccia_S2106)\
**Post date:** [September 3, 2014, 3:36pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864/2 "2014-09-03T15:36:58Z")

</div>

On Wed, Sep 3, 2014 at 9:17 AM, Simone Ciccia S210664 \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> Thanks,  
> Simone Ciccia

We’ve been seeing this issue from a few people recently. I can’t  
duplicate  
the problem. I just did exactly what you did above, though the work  
function doesn’t actually do anything.

Are you potentially adding some interface setter or getter to the class  
and  
not putting it in all the right places (pure virtual in the public  
header,  
then again in the private header, and implemented in the source file)?

Have you added QA code? In qa\_power\_control.py, just add a line to the  
test  
function to create the PWagc.power\_control(x,y) and see if it works  
there.

Tom

---

<div class="post-metadata">

**Author:** ![Simone\_Ciccia\_S2106](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Simone\_Ciccia\_S2106](https://www.ruby-forum.com/u/Simone_Ciccia_S2106)\
**Post date:** [September 3, 2014, 3:58pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864/3 "2014-09-03T15:58:19Z")

</div>

Very thanks for the immediate answer,

Sorry, I forgot that I passed two arguments when the block was created:

$insert valid arguments: float reference, float alpha

while “unsigned int d\_counter” is a normal variable initialized in the  
constructor.

now, in the file power\_control\_impl.h (in short) I added the variables:

```
class power_control_impl : public power_control
{
 private:

```

float d\_alpha, d\_ref;  
unsigned int d\_counter;

and then, in the constructor of the file power\_control\_impl.cc (in  
short) I  
used the settler:

```
power_control_impl::power_control_impl(float alpha, float reference)
  : gr::block("power_control",gr::io_signature::make2(2, 2,

```

sizeof(float), sizeof(float)),  
gr::io\_signature::make(1, 1, sizeof(float))),  
d\_alpha(alpha),  
d\_ref(reference)  
{  
d\_counter=0  
}

the xml file (in short) I think is ok:

PWagc.power\_control($alpha, $reference)

 Alpha alpha float Reference reference float 

is there something in the wrong place?  
thanks for the help!  
Simone

On Wed, 3 Sep 2014 09:35:35 -0400, Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I written and compiled my block with commands:  
> > tb = top\_block(address=options.address)  
> > in this last folder I can see the installed gr-PWagc directory.
> > 
> > Someone can help me please?  
> > If additional information are needed, please ask me… I’m blocked here!
> > 
> > Thanks,  
> > Simone Ciccia
> 
> We’ve been seeing this issue from a few people recently. I can’t  
> duplicate  
> the problem. I just did exactly what you did above, though the work  
> function doesn’t actually do anything.
> 
> Are you potentially adding some interface setter or getter to the class  
> and  
> not putting it in all the right places (pure virtual in the public  
> header,  
> then again in the private header, and implemented in the source file)?
> 
> Have you added QA code? In qa\_power\_control.py, just add a line to the  
> test  
> function to create the PWagc.power\_control(x,y) and see if it works  
> there.

---

<div class="post-metadata">

**Author:** ![Simone\_Ciccia\_S2106](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Simone\_Ciccia\_S2106](https://www.ruby-forum.com/u/Simone_Ciccia_S2106)\
**Post date:** [September 8, 2014, 3:50pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864/4 "2014-09-08T15:50:26Z")

</div>

On Wed, Sep 3, 2014 at 9:57 AM, Simone Ciccia S210664 \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> ```
> power_control_impl::power_control_impl(float alpha, float reference)
> 
> ```
> 
> is there something in the wrong place?  
> thanks for the help!  
> Simone

Yeah, I figured there were two arguments. I just put them as x and y.

One thing that can happen here is if there’s a declared function in the  
public and/or private header that’s not implemented in the .cc file. You  
might have something like that going on, such as not having or deleting  
the  
destructor. Using gr\_modtool should protect you from things like this,  
and  
testing it out on my end here worked fine. Just double-check your work  
to  
make sure you didn’t remove anything you shouldn’t have.

Tom

---

<div class="post-metadata">

**Author:** ![Simone\_Ciccia\_S2106](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e495f1/32.png) [@Simone\_Ciccia\_S2106](https://www.ruby-forum.com/u/Simone_Ciccia_S2106)\
**Post date:** [September 10, 2014, 11:58am UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-block-name/231864/5 "2014-09-10T11:58:54Z")

</div>

Hi,  
I have individuated the error and we are near the solution, thanks to  
all.

I just remember the error that appear when I try to run a simulation of  
my  
new block “power”:

Traceback (most recent call last):  
File “/home/simone/Scrivania/top\_block.py”, line 228, in   
tb = top\_block()  
File “/home/simone/Scrivania/top\_block.py”, line 71, in **init**  
self.t1\_power\_0 = t1.power(0.001, 0.5)  
AttributeError: ‘module’ object has no attribute ‘power’

I tried my block just eliminating the use of the class function  
gr::uhd::usrp\_source and it works.  
So, the error is in the way in which I define and call a new USRP source  
block.

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* INSTRUCTION  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
This is my creation of the new UHD object in the \_impl.cc file of my new  
written block

::uhd::device\_addr\_t addr;

gr::uhd::usrp\_source::sptr my\_usrp\_source =  
gr::uhd::usrp\_source::make(addr, ::uhd::stream\_args\_t(“fc32”));

and then I use this function

DB\_gain = (float) my\_usrp\_source-\>get\_gain(0);

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/

I have some questions:

consider the flowgraph attached in this mail,

first of all, I’m using an usrp (UHD: USRP SOURCE block) with a fixed ip  
address (addr=192.168.10.2), and I set “sudo ifconfig eth0 192.168.10.1”  
and get “addr 192.168.10.2” to setup the device.  
In the same flowgraph, in my created block (my \_impl.cc) now I’m  
creating  
another USRP source block and I don’t understand which address I need to  
use to set correctly the make function (see instruction above) for  
modifying parameters of the same USRP that is working, the USRP with  
address 192.168.10.2.  
In my code I set addr=192.168.10.2

Second, this definition:  
gr::uhd::usrp\_source::sptr my\_usrp\_source =  
gr::uhd::usrp\_source::make(addr, ::uhd::stream\_args\_t(“fc32”));

is sufficient to put it into the general work and no other places to use  
this class??? The compilare does not advice me that there is an error,  
but  
my definition for class usage is not clear and wrong and then I get  
error  
in simulation…

Anyway, is well appreciated if someone can show me the correct way to  
define and use function of other classes into a new created block!

On Mon, 8 Sep 2014 09:48:32 -0400, Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > constructor.  
> > and then, in the constructor of the file power\_control\_impl.cc (in  
> > short)  
> > d\_counter=0
> 
> Yeah, I figured there were two arguments. I just put them as x and y.
> 
> One thing that can happen here is if there’s a declared function in the  
> public and/or private header that’s not implemented in the .cc file. You  
> might have something like that going on, such as not having or deleting  
> the  
> destructor. Using gr\_modtool should protect you from things like this,  
> and
> 
> > > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:
> > > 
> > > > $cmake ../ && make && sudo make install && sudo ldconfig  
> > > > self.PWagc\_power\_control\_0 = PWagc.power\_control(0.001, 0.25)  
> > > > Someone can help me please?  
> > > > function doesn’t actually do anything.
> > > 
> > > Are you potentially adding some interface setter or getter to the  
> > > class
