Skip to content

[Bug]: libxml2.createFileParserCtxt() of libxml2-python not working #28979

Description

@robertkirkman

Problem description

On Desktop Linux, this command works:

python -c "import libxml2; libxml2.createFileParserCtxt('test')"

however, on Termux, the command has this output, which does not match the output on Desktop Linux.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import libxml2; libxml2.createFileParserCtxt('test')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'libxml2' has no attribute 'createFileParserCtxt'

What steps will reproduce the bug?

pkg upgrade
pkg install libxml2-python
python -c "import libxml2; libxml2.createFileParserCtxt('test')"

What is the expected behavior?

No output, or, in the case of test not being an existing file, this output is expected instead:

I/O warning : failed to load "test": No such file or directory
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import libxml2; libxml2.createFileParserCtxt('test')
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/site-packages/libxml2.py", line 1431, in createFileParserCtxt
    if ret is None:raise parserError('xmlCreateFileParserCtxt() failed')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
libxml2.parserError: xmlCreateFileParserCtxt() failed

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_FILE=/data/app/~~V6ZnvtL2KaT1It2i86M9Xw==/com.termux-AnZFMelgltzLjG9LcSfvYQ==/base.apk
TERMUX_APP__APK_RELEASE=F_DROID
TERMUX_APP__APP_VERSION_CODE=1022
TERMUX_APP__APP_VERSION_NAME=0.119.0-beta.3
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__LEGACY_DATA_DIR=/data/data/com.termux
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PID=4511
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c237,c256,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-beta.3
TERMUX__APPS_DIR=/data/user/0/com.termux/termux/apps
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
TERMUX__ROOTFS_DIR=/data/data/com.termux/files
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c237,c256,c512,c768
TERMUX__UID=10237
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# sources.list.d/glibc.list.bak
deb https://packages-cf.termux.dev/apt/termux-glibc/ glibc stable
# sources.list.d/tur.list.bak
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# glibc-repo (sources.list.d/glibc.list)
deb https://packages-cf.termux.dev/apt/termux-glibc/ glibc stable
# sources.list.d/root.list.bak
deb https://packages-cf.termux.dev/apt/termux-root root stable
# sources.list.d/x11.list.bak
deb https://packages-cf.termux.dev/apt/termux-x11 x11 main
# sources.list.d/termux-adb.list
deb https://nohajc.github.io termux extras
# x11-repo (sources.list.d/x11.list)
deb https://packages-cf.termux.dev/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
termux-tools version:
1.45.0
Android version:
13
Kernel build information:
Linux localhost 4.14.190-lineage-gef0cb31b13 #4 SMP PREEMPT Fri Jun 23 13:11:47 CEST 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A705FN
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
Installed termux plugins:
com.termux.widget versionCode:1001
com.termux.api versionCode:1002
com.termux.styling versionCode:1000
com.termux.boot versionCode:1000
com.termux.x11 versionCode:15
com.termux.gui versionCode:7

Activity

  1. robertkirkman commented on Mar 17, 2026

    @robertkirkman
    MemberAuthor

    so far, I tried recompiling the libxml2-python package using ./build-package.sh -I -f libxml2 on the phone inside of Termux, but unfortunately it did not change anything. that seems to indicate that this problem is caused by something that is not related to cross-compilation

  2. robertkirkman commented on Mar 17, 2026

    @robertkirkman
    MemberAuthor

    This affects Termux with:

    • both Python 3.12 and Python 3.13
    • both libxml2 15.1 and libxml2 15.2
    • both termux-apt and termux-pacman
    • both 64-bit and 32-bit
    • both x86 and arm

    therefore, it has been happening for quite a while, and is probably not caused by any recent update.

    Desktop Linux which has libxml2 working in Python has:

    • libxml2 15.1
    • Python 3.13
  3. robertkirkman commented on Mar 17, 2026

    @robertkirkman
    MemberAuthor

    Termux did not always have this problem, though. I suspect that the point the bug was introduced first was some time in between October 6 2025 and March 2 2026.

    That is to say, before October 6 2025, Termux did not have this problem, but some time in between October 6 2025 and March 2 2026, this problem was introduced.

    My heavy backup of Termux from September 2024, retired64 Termux, is not affected by this. That is to say, it can also serve as a preserved, functional example of Termux how it was before this problem appeared.

  4. robertkirkman commented on Mar 18, 2026

    @robertkirkman
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportSomething is not working properly

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions