T
Termux6mo ago
Veka

Running moderngl (and glcontext) python library

Hello! I'm trying to get moderngl python library working on termux. First of all, I encountered this issue during installation pip install moderngl
In file included from glcontext/x11.cpp:5:
/data/data/com.termux/files/usr/include/X11/Xlib.h:44:10: fatal error: 'X11/X.h' file not found
44 | #include <X11/X.h>
| ^~~~~~~~~
1 error generated.
error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
[end of output]
In file included from glcontext/x11.cpp:5:
/data/data/com.termux/files/usr/include/X11/Xlib.h:44:10: fatal error: 'X11/X.h' file not found
44 | #include <X11/X.h>
| ^~~~~~~~~
1 error generated.
error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
[end of output]
And fixed it with apt install xorgproto, after which it installed correctly Then I got an issue when running moderngl.create_context(standalone=True) which complained about lack of libGL.so, which I also fixed with apt install mesa But now I get the following error, that I cannot solve
opengl_context = moderngl.create_context(standalone=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/moderngl/__init__.py", line 1936, in create_context
ctx.mglo, ctx.version_code = mgl.create_context(glversion=require, mode=mode, **settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/glcontext/__init__.py", line 90, in create
return x11.create_context(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: (standalone) XOpenDisplay: cannot open display
opengl_context = moderngl.create_context(standalone=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/moderngl/__init__.py", line 1936, in create_context
ctx.mglo, ctx.version_code = mgl.create_context(glversion=require, mode=mode, **settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/glcontext/__init__.py", line 90, in create
return x11.create_context(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: (standalone) XOpenDisplay: cannot open display
To clarify, the only thing I need moderngl library for is to attempt to compile GLSL shaders and check them for errors, via Context.program() and Context.compute_shader()
Solution:
Ahh nvm, I'm an idiot. I had a typo env DISPLAY:=1 instead of env DISPLAY=:1 So the solution to installing and running moderngl (and glcontext) python library in termux is: Install necessary packages ```sh...
GitHub
GitHub - termux/termux-x11: Termux X11 add-on application.
Termux X11 add-on application. Contribute to termux/termux-x11 development by creating an account on GitHub.
Jump to solution
9 Replies
komo
komo6mo ago
pkg i libx11
Veka
VekaOP6mo ago
Already have that installed, didn't fix
komo
komo6mo ago
CPPFLAGS="-I$PREFIX/include" CFLAGS="-I$PREFIX/include" pip install moderngl
Veka
VekaOP6mo ago
Didn't fix. I uninstalled moderngl and glcontext libraries, cleared cache (pip cache purge), then installed moderngl with your command, but it still shows the same issue with XOpenDisplay: cannot open display
komo
komo6mo ago
you need an X11 display
komo
komo6mo ago
GitHub
GitHub - termux/termux-x11: Termux X11 add-on application.
Termux X11 add-on application. Contribute to termux/termux-x11 development by creating an account on GitHub.
Veka
VekaOP6mo ago
Alright, so I had it for a second there, but then I cleared termux data to try & do it again, to make an exact step by step instructions, and now it no longer works. I've installed the following packages mesa xorgproto libx11 x11-repo termux-x11-nightly, installed latest apk, launched the server via termux-x11 :1 & and then run the python tool with env DISPLAY=:1 command prefix. the same XOpenDisplay: cannot open display error Ok, got it working again, when I ran it with termux-x11 :1 -xstartup "command goes here". Is there a way to fix it so that the server can run in the background while I can interactively run command directly in the shell? So basically the method that I've used in previous message.
Solution
Veka
Veka6mo ago
Ahh nvm, I'm an idiot. I had a typo env DISPLAY:=1 instead of env DISPLAY=:1 So the solution to installing and running moderngl (and glcontext) python library in termux is: Install necessary packages
pgk install mesa xorgproto libx11 x11-repo && pkg install termux-x11-nightly
pgk install mesa xorgproto libx11 x11-repo && pkg install termux-x11-nightly
Install python library
pip install moderngl
pip install moderngl
Install companion app APK from https://github.com/termux/termux-x11 Launch X11 server
termux-x11 :1 &
termux-x11 :1 &
Launch python script with a DISPLAY=:1 prefix
DISPLAY=:1 python script.py
DISPLAY=:1 python script.py
GitHub
GitHub - termux/termux-x11: Termux X11 add-on application.
Termux X11 add-on application. Contribute to termux/termux-x11 development by creating an account on GitHub.
Veka
VekaOP6mo ago
Ty for help!
Want results from more Discord servers?
Add your server