Python3 / comedi?

116 views
Skip to first unread message

Bernd Porr

unread,
Nov 5, 2018, 9:19:23 AM11/5/18
to comed...@googlegroups.com
Hi all,

is anybody using python3 and comedi under Bionic Beaver?

Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
import comedi as c
dev=c.comedi_open('/dev/comedi0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'comedi' has no attribute 'comedi_open'
bp1@bp1-Precision-WorkStation-T5400:~/python$ python

Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import comedi as c
dev=c.comedi_open('/dev/comedi0')

You see it works under Python2 but not Python3. Is there another
approach to it?

/Bernd
-- 
www:    http://www.berndporr.me.uk/
        http://www.linux-usb-daq.co.uk/
	http://www.imdb.com/name/nm3293421/
Mobile: +44 (0)7840 340069
Work:   +44 (0)141 330 5237
        University of Glasgow
        School of Engineering
        Rankine Building, Oakfield Avenue,
        Glasgow, G12 8LT

Bernd Porr

unread,
Nov 5, 2018, 4:45:08 PM11/5/18
to comed...@googlegroups.com

I've just tried Trevor's pycomedi. That's the output from pip below. Won't compile. I've also checked it out from his git. That installs but then the demo programs crash with  internal errors. I guess it's hopelessly out of date? ;)

Was hoping to use Python3 and my USBDUX boxes for teaching but seems to be virtually impossible?

/Bernd


   /usr/local/lib/python3.6/dist-packages/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-build-07z_v5yg/pycomedi/pycomedi/command.pxd
      tree = Parsing.p_module(s, pxd, full_module_name)
   
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
            if self._cmd.chanlist is not NULL:
                _stdlib.free(self._cmd.chanlist)
            if self._cmd.data is not NULL:
                _stdlib.free(self._cmd.data)
   
        cdef _comedi_h.comedi_cmd *get_comedi_cmd_pointer(self) except *:
            ^
    ------------------------------------------------------------
   
    pycomedi/command.pyx:147:9: Signature not compatible with previous declaration
   
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
   
    cdef class Command (object):
        cdef _comedi_h.comedi_cmd _cmd
        cdef public list _fields
   
        cdef _comedi_h.comedi_cmd *get_comedi_cmd_pointer(self)
                                 ^
    ------------------------------------------------------------
   
    pycomedi/command.pxd:26:30: Previous declaration is here
    building 'pycomedi.command' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.6m -c pycomedi/command.c -o build/temp.linux-x86_64-3.6/pycomedi/command.o
    pycomedi/command.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
     #error Do not use this file, it is the result of a failed Cython compilation.
      ^~~~~
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
   
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-07z_v5yg/pycomedi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-k0nrw6m9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-07z_v5yg/pycomedi/

--
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 email to comedi_list...@googlegroups.com.
To post to this group, send email to comed...@googlegroups.com.
Visit this group at https://groups.google.com/group/comedi_list.
For more options, visit https://groups.google.com/d/optout.

Ian Abbott

unread,
Nov 12, 2018, 8:22:14 AM11/12/18
to comed...@googlegroups.com, Bernd Porr
On 05/11/18 14:18, Bernd Porr wrote:
> Hi all,
>
> is anybody using python3 and comedi under Bionic Beaver?
>
> Python 3.6.6 (default, Sep 12 2018, 18:26:19)
> [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import comedi as c
>>>> dev=c.comedi_open('/dev/comedi0')
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: module 'comedi' has no attribute 'comedi_open'

There were some changes to swig/comedi.i back in March 2017 to fix some
Python 3 incompatibilities. The changes are in comedilib 0.11.0, but if
you have the latest 0.10.x versions of the python-comedilib or
python3-comedilib packages installed, they won't work with
libcomedi.so.0.11.x.

You may need to set PYTHON_PATH in the runtime environment to point to
the directory containing locally installed 0.11.x versions of comedi.py
and _comedi.so. (There are no Debian or Ubuntu packages for comedilib
0.11.0 yet.)

>
> bp1@bp1-Precision-WorkStation-T5400:~/python$ python
>
> Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
> [GCC 7.3.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> import comedi as c
>>>> dev=c.comedi_open('/dev/comedi0')
>>>>
> You see it works under Python2 but not Python3. Is there another
> approach to it?
>
> /Bernd



--
-=( Ian Abbott <abb...@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268. Registered address: )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

Bernd Porr

unread,
Nov 19, 2018, 7:23:48 AM11/19/18
to comed...@googlegroups.com, Ian Abbott
Thanks Ian,

I'm using it in a large lab with 160 students and most of them would
struggle to fix it. I think we need to get the wrapper properly going at
some point.

Thanks,

/Bernd
Reply all
Reply to author
Forward
0 new messages