Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use Python API - first example code fails #1791

Open
gmeader opened this issue Oct 10, 2022 · 4 comments
Open

Trying to use Python API - first example code fails #1791

gmeader opened this issue Oct 10, 2022 · 4 comments

Comments

@gmeader
Copy link

gmeader commented Oct 10, 2022

installed ola using these commands:
Ubuntu 20.04.1 LTS
Install ola with python 3 support:

$ sudo apt install git libcppunit-dev libcppunit-1.15-0 uuid-dev pkg-config libncurses5-dev libtool autoconf automake g++ libmicrohttpd-dev libmicrohttpd12 protobuf-compiler libprotobuf-lite17 python-protobuf libprotobuf-dev libprotoc-dev zlib1g-dev bison flex make libftdi-dev libftdi1 libusb-1.0-0-dev liblo-dev libavahi-client-dev python-numpy
$ git clone https://github.com/OpenLightingProject/ola
$ cd ola
$ autoreconf -i
$ PYTHON=python3 ./configure --disable-unittests --disable-examples --disable-osc --enable-http --enable-python-libs
$ make
$ sudo make install
$ sudo ldconfig
]
==== seems ok
started olad - OK

I installed Python bindings for OLA, available as a package:
pip install ola
It installed v0.10.7

Ran the "A simple example to send one frame of DMX data" example code from https://www.openlighting.org/ola/developer-documentation/python-api/
Got the following error message:

/usr/bin/python3.9 /home/glenn/projects/ola/main.py
Traceback (most recent call last):
File "/home/glenn/projects/ola/main.py", line 11, in
client.SendDmx(universe, data, DmxSent)
File "/usr/local/lib/python3.9/dist-packages/ola/OlaClient.py", line 882, in SendDmx
request.data = data.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'

Process finished with exit code 1

Running the Sending Multiple Frames example gives this error:
/usr/bin/python3.9 /home/glenn/projects/ola/main.py
Traceback (most recent call last):
File "/home/glenn/projects/ola/main.py", line 28, in
wrapper.Run()
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 278, in Run
self._ss.Run()
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 197, in Run
self._CheckTimeouts(now)
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 222, in _CheckTimeouts
event.Run()
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 67, in Run
self._callback()
File "/home/glenn/projects/ola/main.py", line 15, in SendDMXFrame
wrapper.AddEvent(TICK_INTERVAL, SendDMXFrame)
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 287, in AddEvent
self._ss.AddEvent(time_in_ms, callback)
File "/usr/local/lib/python3.9/dist-packages/ola/ClientWrapper.py", line 215, in AddEvent
heapq.heappush(self._events, event)
TypeError: '<' not supported between instances of '_Event' and '_Event'

Process finished with exit code 1

@peternewman
Copy link
Member

Hi @gmeader ,

Those are various issues we'd fixed in 0.10.8 or git for Python 3 compatibility.

Can you remove the pip version of OLA (unfortunately 20.04 is missing all our packaged versions) and then just use the version that the OLA make compiles/installs and that should work fine.

I'll talk to the person that built that pip package and try and get it a bit more under control...

@peternewman
Copy link
Member

In terms of integrating the pip stuff, something like this could auto-release to pip for us!
codespell-project/codespell#2523

@hachpai
Copy link

hachpai commented Nov 9, 2022

Hello!
I just success to install olad 0.10.8, then pip install ola, and make everything working by git cloning the repo and copy the content of python/ola in .local/lib/python3.9/site-packages/ola.
Dirty but i can register universes, get new data...

pip install ola
git clone https://github.com/OpenLightingProject/ola.git
cp ola/python/ola/* /home/pi/.local/lib/python3.9/site-packages/ola

@peternewman
Copy link
Member

Hi @hachpai ,

What's the benefit of that over just installing the OLA python stuff via configure/make?

Also just as a warning that will be rather brittle if we fix things in Protobuf or the RDM stuff, running make builtfiles first would cover the first bit, the second bit would involve a bit of both and grabbing files from ola/tools/rdm too (but it will need to be copied into ola/testing/rdm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants