Closed Coderx7 closed 6 months ago
Please try upgrading your packages (specifically you have a matplotlib update waiting)
Thanks for the reminder. I did upgrade but the problem remains unaffected.
I can not reproduce the issue with a clean install of termux and those new opencv packages. The python script ran fine and it shows a chess like image as following.
By the way, the above screenshot is from Linux desktop ssh into termux with X11 forwarding. termux-x11 does not work properly. Also, I can not stop the python script with Ctrl+C but kill
works.
you are only seeing the opencv output, press a key and that window closes, and the matplotlib runs. you can run this script if you don't want to press any keys :
import cv2
import numpy as np
import matplotlib.pyplot as plt
# create a simple image
image = np.kron([[1, 0] * 4, [0, 1] * 4] * 4, np.ones((50, 50))).astype(np.uint8) * 255
# Test opencv
cv2.imshow('checkboard',image)
# wait for 500 ms or a keypress to continue
# 0 means wait indefinitely until a key is pressed
cv2.waitKey(500)
# Test matplotlib
plt.imshow(image)
plt.show()
side note: the x11 works properly, it's the opencv behavior when you use cv2.waitKey(0), you have to press a key, closing the window wouldn't end the app cuz it's still waiting for a key!
After pressing Enter key, I got the following warning.
/data/data/com.termux/files/home/./matplotlib-test.py:12: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
the warning is OK and expected but do you get an output from matplotlib?!
do you get an output from matplotlib?!
No, I did not get any error from matplotlib. Try with a clean termux install if possible. The python package management in termux is a bit inconvenient.
@Biswa96, by output I meant an image! you should get an output, another window showing the same image, the warning only happens when you run this using a python instance and can be ignored. if yes, then I need to dig deeper and see why Im facing this issue!
Yes, I get two window - one with the above image and another one as following screenshot.
Wait a sec, does recompiling packages change the result? I have to create contourpy and kiwisolver packages because my ancient phone can not compile those with lower memory.
yup, that's it, you are getting the expected outputs! I'm not sure about the recompiling though, I dont think recompiling packages on your phone has anything to do with this.
Could you provide the output of pip list
?
here you are
~ $ pip list
Package Version
------------------------- ------------
ai-einblick-prompt 0.1.12
aiohttp 3.8.5
aiohttp-socks 0.8.0
aiorpcX 0.22.1
aiosignal 1.3.1
anyio 3.7.1
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
arrow 1.2.3
asciinema 2.4.0
asttokens 2.2.1
async-lru 2.0.4
async-timeout 4.0.2
attrs 23.1.0
Babel 2.12.1
backcall 0.2.0
beautifulsoup4 4.12.2
bitstring 4.0.2
bleach 6.0.0
certifi 2023.7.22
cffi 1.15.1
charset-normalizer 3.2.0
comm 0.1.4
contourpy 1.2.1
cryptography 42.0.5
cycler 0.11.0
debugpy 1.6.8
decorator 5.1.1
defusedxml 0.7.1
dnspython 2.4.1
Electrum 4.5.4
executing 1.2.0
fastjsonschema 2.18.0
filelock 3.12.2
fonttools 4.42.0
fqdn 1.5.1
frozenlist 1.4.0
idna 3.4
ipykernel 6.25.0
ipython 8.14.0
ipython-genutils 0.2.0
ipywidgets 8.1.0
isoduration 20.11.0
jedi 0.19.0
Jinja2 3.1.2
json5 0.9.14
jsonpointer 2.4
jsonschema 4.18.6
jsonschema-specifications 2023.7.1
jupyter 1.0.0
jupyter_client 8.3.0
jupyter-console 6.6.3
jupyter_core 5.3.1
jupyter-events 0.7.0
jupyter-lsp 2.2.0
jupyter_server 2.7.0
jupyter_server_terminals 0.4.4
jupyterlab 4.0.4
jupyterlab-pygments 0.2.2
jupyterlab_server 2.24.0
jupyterlab-widgets 3.0.8
kiwisolver 1.4.4
MarkupSafe 2.1.3
matplotlib 3.8.4
matplotlib-inline 0.1.6
meson 1.2.0
meson-python 0.13.2
mistune 3.0.1
mpmath 1.3.0
multidict 6.0.4
nbclient 0.8.0
nbconvert 7.7.3
nbformat 5.9.2
nest-asyncio 1.5.7
networkx 3.1
notebook 7.0.1
notebook_shim 0.2.3
numpy 1.26.4
overrides 7.3.1
packaging 23.1
pandas 2.2.2
pandocfilters 1.5.0
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pillow 10.3.0
pip 24.0
platformdirs 3.10.0
prometheus-client 0.17.1
prompt-toolkit 3.0.39
protobuf 3.20.3
psutil 5.9.5
ptyprocess 0.7.0
pure-eval 0.2.2
pybind11 2.11.1
pycparser 2.21
pyfiglet 0.8.post1
Pygments 2.15.1
pyparsing 3.0.9
pypng 0.20220715.0
pyproject-metadata 0.7.1
PyQt5 5.15.10
PyQt5-sip 12.12.2
python-dateutil 2.8.2
python-json-logger 2.0.7
python-socks 2.3.0
pytz 2023.3
PyYAML 6.0.1
pyzmq 25.1.0
QDarkStyle 3.1
qrcode 7.4.2
qtconsole 5.4.3
QtPy 2.3.1
ranger-fm 1.9.3
referencing 0.30.0
requests 2.31.0
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.9.2
Send2Trash 1.8.2
six 1.16.0
sniffio 1.3.0
soupsieve 2.4.1
stack-data 0.6.2
sympy 1.12
terminado 0.17.1
tinycss2 1.2.1
torch 2.1.2
torchaudio 2.0.1
torchvision 0.15.1
tornado 6.3.2
traitlets 5.9.0
typing_extensions 4.7.1
tzdata 2023.3
uri-template 1.3.0
urllib3 2.0.4
wcwidth 0.2.6
webcolors 1.13
webencodings 0.5.1
websocket-client 1.6.1
widgetsnbextension 4.0.8
yarl 1.9.2
~ $
Please update PyQt5-sip package using pip. There should be a version constrain in pyqt5 package. I will add it later.
Problem description
After installing the Opencv package with GUI support Link, I noticed the matplotlib now fails with the following error:
Heres the full error log :
What steps will reproduce the bug?
Install matplotlib Install the latest opencv with GUI support from https://github.com/termux/termux-packages/issues/17542#issuecomment-2052370841 run something like this:
What is the expected behavior?
It should run well without any issues.
System information
termux-info:
Edit:
updated the test script so it doesn't require a keypress indefinitely!
it shows the opencv output then waits 500ms for a keypress, then continues to run the matplotlib codes which should display the same image in another window.