OpenLightingProject / ola

The Open Lighting Architecture - The Travel Adaptor for the Lighting Industry
https://www.openlighting.org/ola/
Other
648 stars 207 forks source link

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

Open gmeader opened 2 years ago

gmeader commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

In terms of integrating the pip stuff, something like this could auto-release to pip for us! https://github.com/codespell-project/codespell/pull/2523

hachpai commented 2 years ago

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 commented 2 years ago

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).