Re: [comedi] Libcomedi python3 binding on Ubuntu 24.04 / Debian 12

Ian Abbott <[email protected]> Wed, 7 May 2025 14:21:38 +0100
Newsgroups gmane.linux.comedi
Organization MEV Ltd.
Message-ID <[email protected]>
Hi,

On 06/05/2025 15:29, Han Hartgers wrote:
> Dear all,
>=20
> Can it be that the python bindings for libcomedi are not working for=20
> python3.x?
>=20
> I tried the example on my ubuntu 24.04 (and Debian 12) and I get the=20
> following error:
> hansan@Desk-computer:~$ python
> Python 3.12.3 (main, Feb =C2=A04 2025, 14:48:35) [GCC 13.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import comedi
>>>> device =3D comedi.comedi_open("/dev/comedi0")
> Traceback (most recent call last):
>  =C2=A0 File "<stdin>", line 1, in <module>
> AttributeError: module 'comedi' has no attribute 'comedi_open'
>>>>=20
>=20
> This does work on older Ubuntu versions like 18.04.=C2=A0 Is there a way =
to=20
> fix this?

According to a comment by =C3=89ric Piel on launchpad bug #1797258:

https://bugs.launchpad.net/ubuntu/+source/comedilib/+bug/1797258

... the problem seems to be that the module is installed in the wrong=20
place, so comedi.comedi needs to be imported, e.g.:

import comedi.comedi as c
device =3D c.comedi_open("/dev/comedi0")

That workaround is not great for portability though, as we expect to be=20
able to use 'import comedi'.

> I also tried pycomedi (https://pypi.org/project/pycomedi/)=C2=A0 but that=
 has=20
> trouble to get compiled.
>=20
> My problem looks to be similar as of Bernd Porr in 2018
> See https://groups.google.com/g/comedi_list/c/MjI7FGp_Xyw/m/J5n2dlIoBAAJ
>=20
> There it was suggested that libcomedi 0.11.x would/could solve this. But=
=20
> that does not look to be the case:
>=20
> hansan@Desk-computer:~$ sudo apt list --installed | grep -i comedi
> libcomedi-dev/noble,now 0.11.0+5-1.1build1 amd64 [installed]
> libcomedi0t64/noble,now 0.11.0+5-1.1build1 amd64 [installed]
> python3-comedilib/noble,now 0.11.0+5-1.1build1 amd64 [installed]
> hansan@Desk-computer:~$ uname -a
> Linux Desk-computer 6.8.0-59-lowlatency #61.1-Ubuntu SMP PREEMPT_DYNAMIC=
=20
> Fri Apr 18 11:13:23 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

There was at least one build bug in comedilib 0.11.0, which presumably=20
was fixed by one of the package maintainer's patches.

comedilib-0.12.0 was released about 5 years ago, but doesn't seem to=20
have been picked up by either Debian or Ubuntu yet.

I really ought to finalize a new release 0.13.0 because it is way overdue!

>=20
>  =C2=A0Is there a way to fix this all to use Python3 to interface with co=
medi=20
> based measurement cards ?
>=20
> Kind regards,
>=20
> Han

Another option is to build and install comedilib from source, but it=20
will install to /usr/local by default, and you may have to set the=20
PYTHONPATH environment variable before importing the comedi module.

--=20
-=3D( Ian Abbott <[email protected]> || MEV Ltd. is a company  )=3D-
-=3D( registered in England & Wales.  Regd. number: 02862268.  )=3D-
-=3D( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=3D-
-=3D( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=3D-

--=20
You received this message because you are subscribed to the Google Groups "=
Comedi: Linux Control and Measurement Device Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/comedi_list=
/3500baa8-ea06-49db-b273-90bbf348074e%40mev.co.uk.