Skip to content

ctypes dlopen failed when use no-gil mode on Android #140041

Closed

Description

@pawanake2333

Bug report

Bug description:

File "python/lib/python3.14t/platform.py", line 1127, in machine
    return uname().machine
           ~~~~~^^
File "python/lib/python3.14t/platform.py", line 1070, in uname
    release = android_ver().release
              ~~~~~~~~~~~^^
File "python/lib/python3.14t/platform.py", line 596, in android_ver
    from ctypes import CDLL, c_char_p, create_string_buffer
File "python/lib/python3.14t/ctypes/__init__.py", line 553, in <module>
    pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
File "python/lib/python3.14t/ctypes/__init__.py", line 462, in __init__
    self._handle = _dlopen(self._name, mode)
                   ~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: dlopen failed: library "libpython3.14.so" not found

I compiled Python 3.14 with the no-gil mode. In this mode, the Python library file is named 'libpython3.14t.so', but ctypes internally still tries to load 'libpython3.14.so', which causes an error.

CPython versions tested on:

3.14

Operating systems tested on:

Other

Linked PRs

Activity

  1. picnixz commented on Oct 13, 2025

    @picnixz
    Member

    Marking as a release-blocker because it may be quite annoying as we announced the official support of free-threading. @hugovk is there a plan to release 3.14.1 earlier (like other outstanding issues that require another release)?

  2. colesbury commented on Oct 13, 2025

    @colesbury
    Contributor

    Is this Android specific?

  3. mhsmith commented on Oct 13, 2025

    @mhsmith
    Member

    Yes:

    if _os.name == "nt":
    pythonapi = PyDLL("python dll", None, _sys.dllhandle)
    elif _sys.platform == "android":
    pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
    elif _sys.platform == "cygwin":
    pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
    else:
    pythonapi = PyDLL(None)

    I think the actual library name is available from sysconfig.

  4. picnixz commented on Oct 13, 2025

    @picnixz
    Member

    Isn't it also cygwin specific?

  5. mhsmith commented on Oct 14, 2025

    @mhsmith
    Member

    Apparently so, but that isn't a supported platform. What they have in common is that they're the only Unix platforms that use a dynamically-linked libpython. Well, I guess iOS does as well, but maybe the PyDLL(None) branch works well enough there. I'll do some experimentation.

  6. changed the title [-]ctypes dlopen failed when use no-gil mode[/-] [+]ctypes dlopen failed when use no-gil mode on Android[/+] on Oct 14, 2025
  7. hugovk commented on Oct 14, 2025

    @hugovk
    Member

    Marking as a release-blocker because it may be quite annoying as we announced the official support of free-threading. @hugovk is there a plan to release 3.14.1 earlier (like other outstanding issues that require another release)?

    Not as yet, let's come up with a fix first and then assess the impact and whether it can wait. At least this doesn't need to hold up today's 3.15.0a1.

  8. picnixz commented on Oct 14, 2025

    @picnixz
    Member

    I'll mark it as a "deferred" blocker for now to avoid thinking it's a true blocker.

  9. added a commit that references this issue on Oct 15, 2025
  10. added 2 commits that reference this issue on Oct 15, 2025
  11. added 2 commits that reference this issue on Oct 15, 2025
  12. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions