analogdevicesinc / gr-iio

IIO blocks for GNU Radio
GNU General Public License v3.0
94 stars 62 forks source link

upgrade-3.8: module 'iio' has no attribute 'pluto_sink' #55

Closed aewag closed 4 years ago

aewag commented 4 years ago

Hi, I ran PyBOMBS to install Gnuradio 3.8 and the analogdevices modules. Therefore I compiled libiio, libad9361 from master branch and gr-iio from upgrade-3.8 branch. Everythink ran fine and also all the blocks are in GRC available. (Ubuntu 18.04, PyBOMBS Version 2.3.3, Prefix Python version is: 2.7.15)

But as soon as I run python and call iio.pluto_sink(...) block (or other blocks in the iio repo) this error message pops up: AttributeError: module 'iio' has no attribute 'pluto_sink'

I don't really know what is happening. Running either Python2 or Python3 does not change anything. In both Python versions I can import iio, but calling pluto_sink fails.

Does anyone has a clue what is going on?

tfcollins commented 4 years ago

Make sure the generated swig module is on path. When you run sudo make install it prints all the files it installs and where for gr-iio

aewag commented 4 years ago

I am not sure whether I understood you correctly. The module gets installed in my pybombs prefix. Snippet of sudo make install:

-- Installing: /home/user/pybombs_gnuradio/lib/python3.6/dist-packages/iio/iio_pluto_sink_swig.py

PYTHONPATH includes python3.6/dist-packages directory.

Checking what is available in a Python3 terminal:

Python 3.6.8 (default, Aug 20 2019, 17:12:48) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iio
>>> iio.
iio.Buffer(                iio.LocalContext(          iio.c_char(                iio.create_string_buffer(
iio.Channel(               iio.NetworkContext(        iio.c_char_p(              iio.get_errno(
iio.ChannelAttr(           iio.Structure(             iio.c_int(                 iio.scan_contexts(
iio.Context(               iio.Trigger(               iio.c_size_t(              iio.version
iio.Device(                iio.XMLContext(            iio.c_ssize_t(             iio.weakref
iio.DeviceAttr(            iio.backends               iio.c_uint(                
iio.DeviceDebugAttr(       iio.c_bool(                iio.c_void_p(

I just had a look again at the Analog Wiki and stumbled upon the blocks moved between different directories.

I moved blocks around:

$ cd ~/pybombs_gnuradio/lib/python3.6/dist-packages
$ cp -r iio/ gnuradio/

And then tried to see what is now available:

>>> import gnuradio.iio as iio
>>> iio.pluto_s
iio.pluto_sink(                      iio.pluto_sink_swigregister(         iio.pluto_source_sptr_swigregister(
iio.pluto_sink_make(                 iio.pluto_source(                    iio.pluto_source_swigregister(
iio.pluto_sink_sptr(                 iio.pluto_source_make(               
iio.pluto_sink_sptr_swigregister(    iio.pluto_source_sptr(               

So everything is there, just at wrong locations. Moving does not really solve the problem as now I have a problem with grc as it only calls import iio not import gnuradio.iio as iio.

Any ideas to fix the importing issue is really appreciated. =)

tfcollins commented 4 years ago

import iio imports the libiio bindings not the gr-iio blocks. Remove iio.py from the python3.6/dist-packages folder

aewag commented 4 years ago

Thank you for your answer! I was able to solve the issue with your help! But I didn't yet really understand how it happened as it was a fresh/clean install, but i could find an iio.py file in python2.7/site-packages. I deleted them and now it runs. For others who ran into the same problem, first check where the source file is located after import and if it matches with the output during calling 'sudo make install':

$ python3
>>> import iio
>>> iio.__file__
'/home/user/pybombs_gnuradio/lib/python2.7/site-packages/iio.py'

After checking what is in the directory, I deleted all iio files:

$ ll lib/python2.7/site-packages/
iio.py iio.pyc libiio-0.18-py2.7.egg-info
$ rm lib/python2.7/site-packages/*iio*
eyobed-dev commented 6 months ago

i solved it by just copying iio folder in the site-packages directory