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?
>
> I tried the example on my ubuntu 24.04 (and Debian 12) and I get the
> following error:
> hansan@Desk-computer:~$ python
> Python 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import comedi
>>>> device = comedi.comedi_open("/dev/comedi0")
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: module 'comedi' has no attribute 'comedi_open'
>>>>
>
> This does work on older Ubuntu versions like 18.04. Is there a way to
> fix this?
According to a comment by Éric 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 = c.comedi_open("/dev/comedi0")
That workaround is not great for portability though, as we expect to be
able to use 'import comedi'.
> I also tried pycomedi (
https://pypi.org/project/pycomedi/) but that has
> trouble to get compiled.
>
> 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
>
> There it was suggested that libcomedi 0.11.x would/could solve this. But
> that does not look to be the case:
>
> 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
> 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
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
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!
>
> Is there a way to fix this all to use Python3 to interface with comedi
> 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.
--
-=( Ian Abbott <
abb...@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. ||
www.mev.co.uk )=-