Linux LIBIIO python bindings

Hey all, I am a bit stuck on getting my system operational.

OS: Ubuntu 18.04 in a VM, host system is Windows 10

LIBIIO: compiled using the cmake build described by AD in https://wiki.analog.com/resources/eval/user-guides/ad-fmcdaq2-ebz/software/linux/applications/libiio

The pluto is recognized and I can interact with it / SSH is fine

PYADI: installed in python 3 using pip

When trying to import the adi package in python3 I get the following error message. I read some things that it may be caused by the incorrect installation of the python bindings but I'm puzzled on how to proceed.

Who can help?

Thanks

>>> import adi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/__init__.py", line 34, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/ad9361.py", line 34, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/context_manager.py", line 34, in <module>
File "/home/bert/temp/libiio/bindings/python/iio.py", line 71, in <module>
_get_backends_count = _lib.iio_get_backends_count
File "/usr/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3: undefined symbol: iio_get_backends_count

Parents
  • 0
    •  Analog Employees 
    on Dec 6, 2019 4:04 PM over 1 year ago

    It appears as the libiio bindings are installed but not the actual library itself.

    Can you run `iio_info -s` from the same directory you are running `import adi` from?

    -Travis

  • Hi Travis, thank you for the fast reply

    the command gives me

    Library version: 0.18 (git tag: 1036e51)
    Compiled with backends: local xml ip usb serial
    Available contexts:
        0: 0456:b673 (Analog Devices Inc. PlutoSDR (ADALM-PLUTO)), serial=104473ce6991000706000d007e2789c931 [usb:1.4.5]

    Additional information: The previous python error shows when running from the /libiio/bindings/python/ directory. When running it from somewhere else the error message is different:

    Python 3.6.9 (default, Nov  7 2019, 10:44:02)
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import adi
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/__init__.py", line 34, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/ad9361.py", line 34, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/context_manager.py", line 34, in <module>
    ModuleNotFoundError: No module named 'iio'

Reply
  • Hi Travis, thank you for the fast reply

    the command gives me

    Library version: 0.18 (git tag: 1036e51)
    Compiled with backends: local xml ip usb serial
    Available contexts:
        0: 0456:b673 (Analog Devices Inc. PlutoSDR (ADALM-PLUTO)), serial=104473ce6991000706000d007e2789c931 [usb:1.4.5]

    Additional information: The previous python error shows when running from the /libiio/bindings/python/ directory. When running it from somewhere else the error message is different:

    Python 3.6.9 (default, Nov  7 2019, 10:44:02)
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import adi
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/__init__.py", line 34, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/ad9361.py", line 34, in <module>
      File "/usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg/adi/context_manager.py", line 34, in <module>
    ModuleNotFoundError: No module named 'iio'

Children
  • 0
    •  Analog Employees 
    on Dec 6, 2019 4:22 PM over 1 year ago in reply to radiohead

    That means that the bindings are not on path.

    I would recommend installing libiio to the standard location (not custom prefix), which is usually /usr/lib, and making sure the bindings are on path.

    There is a note about this in the doc: analogdevicesinc.github.io/.../quick.html

    -Travis

  • Which is exactly whay I did. I cloned the pyadi-iio github project, and installed the package using

    python3 setup.py install.

    Here are the last lines from the process. It installed just fine?

    removing 'build/bdist.linux-x86_64/egg' (and everything under it)
    Processing pyadi_iio-0.0.5-py3.6.egg
    Removing /usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg
    Copying pyadi_iio-0.0.5-py3.6.egg to /usr/local/lib/python3.6/dist-packages
    pyadi-iio 0.0.5 is already the active version in easy-install.pth

    Installed /usr/local/lib/python3.6/dist-packages/pyadi_iio-0.0.5-py3.6.egg
    Processing dependencies for pyadi-iio==0.0.5
    Searching for numpy==1.18.0rc1
    Best match: numpy 1.18.0rc1
    Processing numpy-1.18.0rc1-py3.6-linux-x86_64.egg
    numpy 1.18.0rc1 is already the active version in easy-install.pth

  • 0
    •  Analog Employees 
    on Dec 6, 2019 5:59 PM over 1 year ago in reply to radiohead

    That is pyadi-iio, not libiio. It looks like libiio is just in the directory "/home/bert/temp/libiio/" and not installed into a system path.

    -Travis

  • Sorry about that Trevis, I was confused because your link was referring to the pyadi install. The outcome of the make install of libiio is shown below, it installs just fine and I can call the executables as demonstrated above.

    I think it has something to do with the binding of the pyadi module to the libiio driver bindings. Referring to https://ez.analog.com/linux-device-drivers/linux-software-drivers/f/q-a/116409/libiio---python-bindings

    gives a very similar problem but I have no clue how to implement this in my machine on python 3.

    How do install the iio bindings on my file system?

    b41dd32c59194e_icgraph.md5
    -- Up-to-date: /usr/share/doc/libiio0-doc/html/annotated.html
    -- Up-to-date: /usr/share/doc/libiio0-doc/html/group__TopLevel_ga55574e54de682499c5c08566c652114a_icgraph.md5
    -- Up-to-date: /usr/share/doc/libiio0-doc/html/group__Device_ga41582140b8e1fe98148e51ae1350b816_icgraph.md5
    -- Up-to-date: /usr/share/doc/libiio0-doc/html/group__Device_ga176d11776f916c8148c6dfa1368cea3c_cgraph.png
    -- Up-to-date: /lib/udev/rules.d/90-libiio.rules
    -- Up-to-date: /usr/bin/iio_genxml
    -- Up-to-date: /usr/bin/iio_info
    -- Up-to-date: /usr/bin/iio_attr
    -- Up-to-date: /usr/bin/iio_readdev
    -- Up-to-date: /usr/bin/iio_reg
    -- Up-to-date: /usr/bin/iio_writedev
    -- Up-to-date: /usr/bin/iio_adi_xflow_check
    -- Up-to-date: /usr/sbin/iiodµ

  • 0
    •  Analog Employees 
    on Dec 6, 2019 6:55 PM over 1 year ago in reply to radiohead

    When you do make install it tells you where it puts the iio.py file. When built with python3 it usually puts them in something similar to (say or 3.6): /usr/lib/python3.6/site-package

    Therefore the export command would be:

    export PYTHONPATH=$PYTHONPATH:'/usr/lib/python3.6/site-package

    One thing I would also mention, pyadi-iio works fine on Windows as well. See the Windows section here about installing the bindings: https://wiki.analog.com/resources/tools-software/linux-software/pyadi-iio#prerequisites

    -Travis