Open AWSb24 opened 3 years ago
This is because tp_print was removed in python3.9 (and only deprecated in 3.8). You can ignore the warnings.
You can solve this on a raspberry pi using pyenv to install python3.8. The following is based on my shell history on a raspberry pi 3 running ubuntu 21.04 64-bit. If something isn't working, let me know.
We're adding things to root, since root needs to run the library to work properly.
curl https://pyenv.run | sudo bash
Add the following to /root/.bashrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
Finally run the following in a root shell sudo su
. cd
to the root of the rgb matrix git repo for the make commands.
apt install -y libbz2-dev libreadline-dev libssl-dev
pyenv install 3.8.10
pyenv global 3.8.10
pip install Pillow
make build-python PYTHON=$(which python3.8)
make install-python PYTHON=$(which python3.8)
Then you can run things like
/home/ubuntu/rpi-rgb-led-matrix/bindings/python/samples/runtext.py --led-gpio-mapping=adafruit-hat --text="Hello, world!"
These .cpp
files were compiled by old cython. If you don't want to downgrade to python 3.8, you can recompile them with newer cython:
python3 -m pip install cython
cd path_to_repo/bindings/python/rgbmatrix/
python3 -m cython -3 --cplus *.pyx
It took a slight variation on @nvski's comment for me to succeed with Python 3.9.5. I needed to use language_level=2
instead of 3:
python3 -m cython -2 --cplus *.pyx
But with that, I was able to get it working properly in pyenv local 3.9.5
.
Seems like it can be fixed in code.
rename tp_print to tp_vectorcall_offset in /bindings/python/rgbmatrix/core.cpp /bindings/python/rgbmatrix/graphics.cpp
@sityware You saying renaming every mention of tp_print in each line to tp vectorcall_offset? for both core and grahpics? nothing else on top of this?
That seems to fix the issue. I just did a search and replace for tp_print to tp_vectorcall_offset in core.cpp and graphics.cpp, and after that I can build and successfully run the python samples with Python 3.9.2.
I've updated now updated the pre-generated cpp files with the latest cython; can you test if this is now working for you ?
I tried to run make according to the readme on the python binding. It results in several warnings and one error. I am running python3.9 on an RPI4.
rgbmatrix/graphics.cpp:3442:41: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’ 3442 | __pyx_type_9rgbmatrix_8graphics_Color.tp_print = 0; | ^~~~~~~~ rgbmatrix/graphics.cpp:3450:40: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’ 3450 | __pyx_type_9rgbmatrix_8graphics_Font.tp_print = 0; |
How can I solve this?