all Python 3Linux · macOSplatformfunction
platform.libc_ver()
specific operating systems
Tries to detect the C library and its version (by default, the glibc installed on the system): ('glibc', '2.39'); ('', '') on failure.
Syntax
lib, version = platform.libc_ver(executable=None, lib='', version='', chunksize=16384)
Without executable it first asks os.confstr('CS_GNU_LIBC_VERSION') and answers with the glibc installed on the system; it scans the executable only if that fails or a file is passed explicitly. So libc_ver(sys.executable) may answer differently, with the highest glibc version the binary itself requires. On macOS and Windows it usually returns empty strings; musl is detected since 3.14. It helps decide, for example, whether manylinux wheels will work.
Examples
import platform
lib, version = platform.libc_ver()
print(lib, version) # → ? например glibc 2.39; на musl, macOS и Windows пусто
try:
platform.libc_ver(executable='no_such_binary')
except FileNotFoundError as e:
print(type(e).__name__) # → FileNotFoundError — функция читает сам файл
See also
Open in the full glossarydocs.python.orgReport an inaccuracy