Re: [comedi] Libcomedi python3 binding on Ubuntu 24.04 / Debian 12
Ian Abbott <[email protected]> Wed, 21 May 2025 10:07:53 +0100
| Newsgroups | gmane.linux.comedi |
|---|---|
| Organization | MEV Ltd. |
| Message-ID | <[email protected]> |
On 07/05/2025 14:21, Ian Abbott wrote:
> Hi,
>=20
> On 06/05/2025 15:29, Han Hartgers wrote:
>> Dear all,
>>
>> Can it be that the python bindings for libcomedi are not working for=20
>> python3.x?
>>
>> 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=C2=A0 File "<stdin>", line 1, in <module>
>> AttributeError: module 'comedi' has no attribute 'comedi_open'
>>>>>
>>
>> This does work on older Ubuntu versions like 18.04.=C2=A0 Is there a way=
to=20
>> fix this?
>=20
> According to a comment by =C3=89ric Piel on launchpad bug #1797258:
>=20
> https://bugs.launchpad.net/ubuntu/+source/comedilib/+bug/1797258
>=20
> ... the problem seems to be that the module is installed in the wrong=20
> place, so comedi.comedi needs to be imported, e.g.:
>=20
> import comedi.comedi as c
> device =3D c.comedi_open("/dev/comedi0")
>=20
> That workaround is not great for portability though, as we expect to be=
=20
> able to use 'import comedi'.
I found a better workaround is to add a new file:
/usr/lib/python3/dist-packages/comedi/__init__.py
containing the single line:
from .comedi import *
--=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=
/c943b4ea-c153-4a53-bc02-466dae28ceda%40mev.co.uk.