# AttributeError: 'module' object has no attribute 'hamming'

**URL:** <https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200>\
**Category:** GNU Radio\
**Created:** [February 14, 2015, 8:18am UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200 "2015-02-14T08:18:51Z")\
**Posts on this page:** 6\
**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:** [February 14, 2015, 8:18am UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/1 "2015-02-14T08:18:51Z")

</div>

Hi ,  
I wrote a Out of Tree module for hamming code using ITPP library . It  
compiled when i ran the cmake… , make and make install commands without  
error . I used the block in a flowgraph and the python script thus  
generated throws an error while executing it which looks like this .

Traceback (most recent call last):  
File “/home/iiitd/Desktop/hamming.py”, line 62, in   
tb = hamming()  
File “/home/iiitd/Desktop/hamming.py”, line 33, in **init**  
self.wsi\_hamming\_0 = wsi.hamming(3)  
AttributeError: ‘module’ object has no attribute ‘hamming’

I then checked the $PYTHONPATH and made sure it points to the directory  
where the files associated with the block are installed during make  
install  
ie /usr/local/lib/python2.7/dist-packages instead to  
/opt/qt/lib/python2.7/dist-packages .

It would be really thankful if somebody helps me sort this out .

The link to the my OOT code is  
[https://www.dropbox.com/sh/8tstm4ckaphsis/AAD0cbS5eelaoaIe0gUExCBea?dl=0](https://www.dropbox.com/sh/8tstm4ckaphsis/AAD0cbS5eelaoaIe0gUExCBea?dl=0)

Thanks  
Abhinav J.

---

<div class="post-metadata">

**Author:** ![Abhinav\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@Abhinav\_J](https://www.ruby-forum.com/u/Abhinav_J)\
**Post date:** [February 15, 2015, 12:42am UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/2 "2015-02-15T00:42:10Z")

</div>

I ran into this myself with a custom Python block. I was unable to  
resolve it. I gave up. Interested to learn a fix as well.

---

<div class="post-metadata">

**Author:** ![Abhinav\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@Abhinav\_J](https://www.ruby-forum.com/u/Abhinav_J)\
**Post date:** [February 17, 2015, 4:05pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/3 "2015-02-17T16:05:58Z")

</div>

On Sat, Feb 14, 2015 at 2:17 AM, Abhinav J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> self.wsi_hamming_0 = wsi.hamming(3)
> 
> ```
> 
> The link to the my OOT code is  
> [Dropbox - Error - Simplify your life](https://www.dropbox.com/sh/8tstm4ckaphsis/AAD0cbS5eelaoaIe0gUExCBea?dl=0)
> 
> Thanks  
> Abhinav J.

Did you use gr\_modtool to build the OOT project?

Are you sure you are linking against the ITPP library correctly? If you  
ldd  
on your resulting .so file, does it show it links properly?

Is your block in Python or in C++?

What version of GNU Radio are you running?

That link you sent goes nowhere.

You can run “gdb --args python hamming.py” to see a backtrace of where  
the  
problem is really happening.

Tom

---

<div class="post-metadata">

**Author:** ![Abhinav\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@Abhinav\_J](https://www.ruby-forum.com/u/Abhinav_J)\
**Post date:** [February 17, 2015, 5:06pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/4 "2015-02-17T17:06:04Z")

</div>

Hi ,  
Sorry for not providing all the info . I dont know what happened to the  
link though .  
I used gr\_modtool to create the OOT module ;  
I wrote the module in C++ and i am using GNU Radio 3.7.6  
I have created a git repository :

> **[gr-wsi/Documents/gr-wsi at master · Jadoobaba/gr-wsi](https://github.com/Jadoobaba/gr-wsi/tree/master/Documents/gr-wsi)**
>
> master/Documents/gr-wsi

ldd on the .so file has the following output .  
iiitd@iiitd-ThinkPad-W530:/usr/local/lib$ ldd libgnuradio-wsi.so  
linux-vdso.so.1 =\> (0x00007fffc59fe000)  
libboost\_system.so.1.53.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_system.so.1.53.0 (0x00007f79fc959000)  
libgnuradio-runtime-3.7.6.1.so.0.0.0 =\>  
/usr/local/lib/libgnuradio-runtime-3.7.6.1.so.0.0.0 (0x00007f79fc689000)  
libgnuradio-pmt-3.7.6.1.so.0.0.0 =\>  
/usr/local/lib/libgnuradio-pmt-3.7.6.1.so.0.0.0 (0x00007f79fc440000)  
libstdc++.so.6 =\> /usr/lib/x86\_64-linux-gnu/libstdc++.so.6  
(0x00007f79fc13c000)  
libgcc\_s.so.1 =\> /lib/x86\_64-linux-gnu/libgcc\_s.so.1  
(0x00007f79fbf26000)  
libc.so.6 =\> /lib/x86\_64-linux-gnu/libc.so.6 (0x00007f79fbb5d000)  
libvolk.so.0.0.0 =\> /usr/local/lib/libvolk.so.0.0.0  
(0x00007f79fb80f000)  
libboost\_filesystem.so.1.53.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_filesystem.so.1.53.0  
(0x00007f79fb5f9000)  
libboost\_thread.so.1.53.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_thread.so.1.53.0 (0x00007f79fb3e2000)  
libpthread.so.0 =\> /lib/x86\_64-linux-gnu/libpthread.so.0  
(0x00007f79fb1c5000)  
liblog4cpp.so.5 =\> /usr/lib/liblog4cpp.so.5 (0x00007f79faf85000)  
librt.so.1 =\> /lib/x86\_64-linux-gnu/librt.so.1 (0x00007f79fad7c000)  
libm.so.6 =\> /lib/x86\_64-linux-gnu/libm.so.6 (0x00007f79faa78000)  
/lib64/ld-linux-x86-64.so.2 (0x00007f79fcd87000)  
liborc-0.4.so.0 =\> /usr/lib/x86\_64-linux-gnu/liborc-0.4.so.0  
(0x00007f79fa7f8000)  
libnsl.so.1 =\> /lib/x86\_64-linux-gnu/libnsl.so.1  
(0x00007f79fa5de000)

While running gdb --args python hamming.py has the following result .  
(gdb) run  
Starting program: /usr/bin/python hamming.py  
[Thread debugging using libthread\_db enabled]  
Using host libthread\_db library  
“/lib/x86\_64-linux-gnu/libthread\_db.so.1”.  
[New Thread 0x7fffe2576700 (LWP 4704)]  
[New Thread 0x7fffe1d75700 (LWP 4705)]  
[New Thread 0x7fffe0a9a700 (LWP 4706)]  
[New Thread 0x7fffd3fff700 (LWP 4707)]  
[New Thread 0x7fffd37fe700 (LWP 4708)]  
Traceback (most recent call last):  
File “hamming.py”, line 62, in   
tb = hamming()  
File “hamming.py”, line 33, in **init**  
self.wsi\_hamming\_0 = wsi.hamming(3)  
AttributeError: ‘module’ object has no attribute ‘hamming’  
[Thread 0x7fffd37fe700 (LWP 4708) exited]  
[Thread 0x7fffe0a9a700 (LWP 4706) exited]  
[Thread 0x7fffe1d75700 (LWP 4705) exited]  
[Thread 0x7fffe2576700 (LWP 4704) exited]  
[Thread 0x7ffff7fd6740 (LWP 4699) exited]  
[Inferior 1 (process 4699) exited with code 01]

Thanks in advance  
Abhinav J.

---

<div class="post-metadata">

**Author:** ![Abhinav\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@Abhinav\_J](https://www.ruby-forum.com/u/Abhinav_J)\
**Post date:** [February 17, 2015, 4:09pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/5 "2015-02-17T16:09:44Z")

</div>

On Sat, Feb 14, 2015 at 6:41 PM, Richard B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I ran into this myself with a custom Python block. I was unable to resolve  
> it. I gave up. Interested to learn a fix as well.

I don’t think this is a Python block since he’s linking against ITPP,  
but  
it’s not specified in his original question, so I can’t be sure.

Anyways, I just tried making a Python block in an OOT project and it  
works  
just fine.

$ gr\_modtool nm  
Name of the new module: testpy  
Creating out-of-tree module in ./gr-testpy… Done.  
Use ‘gr\_modtool add’ to add a new block to this currently empty module.

$ cd gr-testpy  
$ gr\_modtool add  
GNU Radio module name identified: testpy  
(‘sink’, ‘source’, ‘sync’, ‘decimator’, ‘interpolator’, ‘general’,  
‘tagged\_stream’, ‘hier’, ‘noblock’)  
Enter block type: sync  
Language (python/cpp): python  
Language: Python  
Enter name of block/code (without module name prefix): test01  
Block/code identifier: test01  
Enter valid argument list, including default arguments:  
Add Python QA code? [Y/n]  
Adding file ‘python/test01.py’…  
Adding file ‘python/qa\_test01.py’…  
Editing python/CMakeLists.txt…  
Adding file ‘grc/testpy\_test01.xml’…  
Editing grc/CMakeLists.txt…

$ mkdir build; cd build  
$ cmake -DCMAKE\_INSTALL\_PREFIX=/opt/gr ../  
$ make  
$ make install  
$ ipython  
In [1]: import testpy

In [2]: dir(testpy)  
Out[2]:  
[‘ **builtins** ’,  
‘ **doc** ’,  
‘ **file** ’,  
‘ **name** ’,  
‘ **package** ’,  
‘ **path** ’,  
‘test01’]

In [3]: a = testpy.test01()

Worked fine. You’re not the only person with this problem, but no one  
has  
yet shown me how to reproduce the error.

Tom

---

<div class="post-metadata">

**Author:** ![Abhinav\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@Abhinav\_J](https://www.ruby-forum.com/u/Abhinav_J)\
**Post date:** [February 17, 2015, 5:24pm UTC](https://www.ruby-forum.com/t/attributeerror-module-object-has-no-attribute-hamming/234200/6 "2015-02-17T17:24:46Z")

</div>

On Tue, Feb 17, 2015 at 11:04 AM, Abhinav J.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> linux-vdso.so.1 => (0x00007fffc59fe000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f79fbb5d000)
> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f79faa78000)
> /lib64/ld-linux-x86-64.so.2 (0x00007f79fcd87000)
> liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0
> 
> ```
> 
> (0x00007f79fa7f8000)  
> libnsl.so.1 =\> /lib/x86\_64-linux-gnu/libnsl.so.1 (0x00007f79fa5de000)

Yep, that tells you it right there. You are not linking against the ITPP  
library. Here’s the change you need to make to your lib/CMakeLists.txt  
file:

add\_library(gnuradio-wsi SHARED ${wsi\_sources})  
-target\_link\_libraries(gnuradio-wsi ${Boost\_LIBRARIES}  
${GNURADIO\_ALL\_LIBRARIES})  
+target\_link\_libraries(gnuradio-wsi ${Boost\_LIBRARIES} ${wsi\_libs})  
set\_target\_properties(gnuradio-wsi PROPERTIES DEFINE\_SYMBOL  
“gnuradio\_wsi\_EXPORTS”)

You’ve created a wsi\_libs variable already, but never added this to the  
target\_link\_libraries call. So when trying to open the shared library  
and  
make ITPP calls, you couldn’t, which was causing the import to fail.  
Notice  
all of the extra libraries it links against when you make this change  
(libitpp.so, libblas.so, etc., etc.):

$ ldd lib/libgnuradio-wsi.so  
linux-vdso.so.1 =\> (0x00007fff5d8a1000)  
libboost\_system.so.1.54.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_system.so.1.54.0 (0x00007f9228b6f000)  
libgnuradio-runtime-3.7.7git.so.0.0.0 =\>  
/opt/gr/lib/libgnuradio-runtime-3.7.7git.so.0.0.0 (0x00007f922889f000)  
libgnuradio-pmt-3.7.7git.so.0.0.0 =\>  
/opt/gr/lib/libgnuradio-pmt-3.7.7git.so.0.0.0 (0x00007f9228657000)  
libitpp.so.8 =\> /usr/lib/libitpp.so.8 (0x00007f9228088000)  
libstdc++.so.6 =\> /usr/lib/x86\_64-linux-gnu/libstdc++.so.6  
(0x00007f9227d83000)  
libgcc\_s.so.1 =\> /lib/x86\_64-linux-gnu/libgcc\_s.so.1  
(0x00007f9227b6d000)  
libc.so.6 =\> /lib/x86\_64-linux-gnu/libc.so.6 (0x00007f92277a7000)  
libvolk.so.0.0.0 =\> /opt/gr/lib/libvolk.so.0.0.0 (0x00007f9227481000)  
libboost\_filesystem.so.1.54.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_filesystem.so.1.54.0  
(0x00007f922726b000)  
libboost\_thread.so.1.54.0 =\>  
/usr/lib/x86\_64-linux-gnu/libboost\_thread.so.1.54.0 (0x00007f9227055000)  
libpthread.so.0 =\> /lib/x86\_64-linux-gnu/libpthread.so.0  
(0x00007f9226e36000)  
liblog4cpp.so.5 =\> /usr/lib/liblog4cpp.so.5 (0x00007f9226bf6000)  
librt.so.1 =\> /lib/x86\_64-linux-gnu/librt.so.1 (0x00007f92269ee000)  
libm.so.6 =\> /lib/x86\_64-linux-gnu/libm.so.6 (0x00007f92266e7000)  
libfftw3.so.3 =\> /usr/lib/x86\_64-linux-gnu/libfftw3.so.3  
(0x00007f92262ef000)  
liblapack.so.3 =\> /usr/lib/liblapack.so.3 (0x00007f9225b53000)  
libblas.so.3 =\> /usr/lib/libblas.so.3 (0x00007f9225586000)  
libgomp.so.1 =\> /usr/lib/x86\_64-linux-gnu/libgomp.so.1  
(0x00007f9225377000)  
/lib64/ld-linux-x86-64.so.2 (0x00007f9228fb1000)  
liborc-0.4.so.0 =\> /usr/lib/x86\_64-linux-gnu/liborc-0.4.so.0  
(0x00007f92250f5000)  
libnsl.so.1 =\> /lib/x86\_64-linux-gnu/libnsl.so.1 (0x00007f9224eda000)  
libgfortran.so.3 =\> /usr/lib/x86\_64-linux-gnu/libgfortran.so.3  
(0x00007f9224bc1000)  
libquadmath.so.0 =\> /usr/lib/x86\_64-linux-gnu/libquadmath.so.0  
(0x00007f9224984000)

I was hoping that the gdb call would tell us of the failure going on in  
inside the module while it was trying to import it, but looks like  
that’s  
opaque here. Oh well.

Also, just as an aside, your git needs a bit of work. You’ve added the  
build directory, which you should never do, as well as all of your  
temporary emacs files (the files ending in ~). And for some reason, your  
root directory is Documents with gr-wsi underneath. Just some tips to  
make  
it easier to share your code in the future.

Tom
