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

Han Hartgers <[email protected]> Wed, 7 May 2025 23:01:49 +0800
Newsgroups gmane.linux.comedi
Message-ID <CAGk8maku-kdSN8+T47SPMJEcqha_kaXdOR8Qe-16qw6M-e2D7g@mail.gmail.com>
--000000000000f159ca06348d0381
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Dear Ian,

On Wed, May 7, 2025 at 9:21=E2=80=AFPM Ian Abbott <[email protected]> wrote=
:

> Hi,
>
> On 06/05/2025 15:29, Han Hartgers wrote:
> > Dear all,
> >
> > Can it be that the python bindings for libcomedi are not working for
> > python3.x?
> >
>
> > This does work on older Ubuntu versions like 18.04.  Is there a way to
> > 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
> 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
> able to use 'import comedi'.


Thanks this is indeed working for me as well.


> > I also tried pycomedi (https://pypi.org/project/pycomedi/)  but that
> has
> > trouble to get compiled.
> >
>
I need to correct myself here;  Compiling/installing pycomedi looks to be
working for both Ubuntu 25.04 and Debian 12.  I must have done something
wrong when I tried earlier.


> >
> >   Is there a way to fix this all to use Python3 to interface with comed=
i
> > based measurement cards ?
> >
> > Kind regards,
> >
> > Han
>
> Another option is to build and install comedilib from source, but it
> will install to /usr/local by default, and you may have to set the
> PYTHONPATH environment variable before importing the comedi module.
>
>
I will look at this as well.  I should get that working.   you pointed me
in the right direction.

--=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=
/CAGk8maku-kdSN8%2BT47SPMJEcqha_kaXdOR8Qe-16qw6M-e2D7g%40mail.gmail.com.

--000000000000f159ca06348d0381
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Dear Ian,</div><br><div class=3D"gmail_qu=
ote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Ma=
y 7, 2025 at 9:21=E2=80=AFPM Ian Abbott &lt;<a href=3D"mailto:[email protected]=
o.uk">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,=
204);padding-left:1ex">Hi,<br>
<br>
On 06/05/2025 15:29, Han Hartgers wrote:<br>
&gt; Dear all,<br>
&gt; <br>
&gt; Can it be that the python bindings for libcomedi are not working for <=
br>
&gt; python3.x?<br>
&gt; <br><br>
&gt; This does work on older Ubuntu versions like 18.04.=C2=A0 Is there a w=
ay to <br>
&gt; fix this?<br>
<br>
According to a comment by =C3=89ric Piel on launchpad bug #1797258:<br>
<br>
<a href=3D"https://bugs.launchpad.net/ubuntu/+source/comedilib/+bug/1797258=
" rel=3D"noreferrer" target=3D"_blank">https://bugs.launchpad.net/ubuntu/+s=
ource/comedilib/+bug/1797258</a><br>
<br>
... the problem seems to be that the module is installed in the wrong <br>
place, so comedi.comedi needs to be imported, e.g.:<br>
<br>
import comedi.comedi as c<br>
device =3D c.comedi_open(&quot;/dev/comedi0&quot;)<br>
<br>
That workaround is not great for portability though, as we expect to be <br=
>
able to use &#39;import comedi&#39;.</blockquote><div><br></div><div>Thanks=
 this is indeed working for me as well.</div><div>=C2=A0</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex">
&gt; I also tried pycomedi (<a href=3D"https://pypi.org/project/pycomedi/" =
rel=3D"noreferrer" target=3D"_blank">https://pypi.org/project/pycomedi/</a>=
)=C2=A0 but that has <br>
&gt; trouble to get compiled.<br>
&gt; <br></blockquote><div>I need to correct myself here;=C2=A0 Compiling/i=
nstalling pycomedi looks to be working for both Ubuntu 25.04 and Debian 12.=
=C2=A0 I must have done something wrong when I tried earlier.</div><div></d=
iv><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; =
<br>
&gt;=C2=A0 =C2=A0Is there a way to fix this all to use Python3 to interface=
 with comedi <br>
&gt; based measurement cards ?<br>
&gt; <br>
&gt; Kind regards,<br>
&gt; <br>
&gt; Han<br>
<br>
Another option is to build and install comedilib from source, but it <br>
will install to /usr/local by default, and you may have to set the <br>
PYTHONPATH environment variable before importing the comedi module.<br>
<br></blockquote><div><br></div><div>I will look at this as well.=C2=A0 I s=
hould get that working.=C2=A0=C2=A0 you pointed me in the right direction. =
<br></div><div>=C2=A0</div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Comedi: Linux Control and Measurement Device Interface&quot; group.<br=
 />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">comedi_=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
comedi_list/CAGk8maku-kdSN8%2BT47SPMJEcqha_kaXdOR8Qe-16qw6M-e2D7g%40mail.gm=
ail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d=
/msgid/comedi_list/CAGk8maku-kdSN8%2BT47SPMJEcqha_kaXdOR8Qe-16qw6M-e2D7g%40=
mail.gmail.com</a>.<br />

--000000000000f159ca06348d0381--