Registry / http-networking / glfw
library2.10.2pypypi✓ verified 25d ago

glfw (pyGLFW) is a ctypes-based wrapper for GLFW3, a cross-platform library for OpenGL, OpenGL ES and Vulkan development. It simplifies window creation, context management, and input handling in Python, providing a near one-to-one mapping to the C API with Pythonic naming conventions. The current version is 2.10.0, and it maintains an active release cadence with regular updates.

pip install glfw
INSTALL
IMPORT
SIG · GLFW
G
glfw
http-networkingpythonv2.10.2
Install
1.6s avg
Import
92ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.10.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.092s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

glfw
import glfw
from glfw.GLFW import *
The modern pyGLFW API removes the 'glfw' and 'GLFW_' prefixes and uses snake_case for functions and constants (e.g., `glfw.init()` instead of `glfwInit()`, `glfw.KEY_ESCAPE` instead of `GLFW_KEY_ESCAPE`). Direct `from glfw.GLFW import *` is an older pattern or for strict C API adherence.

This quickstart initializes GLFW, creates a basic window, sets up an OpenGL rendering context, and runs a simple event loop. It clears the window with a solid color until the user closes it. For actual rendering, you would integrate OpenGL (as shown with `OpenGL.GL`) or Vulkan commands within the main loop.

import glfw import OpenGL.GL as gl def main(): # Initialize the library if not glfw.init(): raise RuntimeError("Failed to initialize GLFW") # Create a windowed mode window and its OpenGL context window = glfw.create_window(640, 480, "Hello pyGLFW", None, None) if not window: glfw.terminate() raise RuntimeError("Failed to create GLFW window") # Make the window's context current glfw.make_context_current(window) # Set viewport and clear color gl.glViewport(0, 0, 640, 480) gl.glClearColor(0.2, 0.3, 0.4, 1.0) # Loop until the user closes the window while not glfw.window_should_close(window): # Render here gl.glClear(gl.GL_COLOR_BUFFER_BIT) # Swap front and back buffers glfw.swap_buffers(window) # Poll for and process events glfw.poll_events() glfw.terminate() if __name__ == "__main__": main()
Debug
Known issues
breakingThe pyGLFW API (current 'glfw' PyPI package) translates GLFW C functions from `camelCase` with a `glfw` prefix (e.g., `glfwGetVersion`) to Pythonic `snake_case` without the prefix (e.g., `glfw.get_version()`). Similarly, constants like `GLFW_KEY_ESCAPE` become `glfw.KEY_ESCAPE`. Code written for the direct C API or older Python wrappers will need adaptation.
fix
Refactor calls to use `glfw.snake_case_function_name()` and `glfw.CONSTANT_NAME`.
affects: All versions (since the project's inception for GLFW3 bindings)
gotchaDespite Python wheels often including the GLFW C shared library for convenience (Windows, macOS, Linux), an `ImportError: Failed to load GLFW3 shared library` can occur. This usually means the native GLFW C library is not found or is incompatible. Users might need to install it via their system's package manager (e.g., `sudo apt install libglfw3 libglfw3-dev` on Debian/Ubuntu, `brew install glfw` on macOS) or compile it from source, ensuring the shared library is discoverable.
fix
Ensure the native GLFW C library is correctly installed and accessible on your system's library search paths. Environment variables like `PYGLFW_LIBRARY` can be set to point to a specific library path, and `PYGLFW_LIBRARY_VARIANT` (e.g., 'wayland' or 'x11') can be used on Linux to explicitly select the variant.
affects: All versions
gotchaVersion `2.7.0` included GLFW 3.4 functions in the Python wrapper but explicitly noted that GLFW 3.4 was *not* included in Python wheels due to build issues on various systems (e.g., manylinux 2014). This could lead to unexpected behavior or missing functionality if a user expected bundled GLFW 3.4 features. This was resolved in `2.8.0` with an update to GLFW 3.4.
fix
Upgrade to `glfw>=2.8.0` to ensure proper bundling of GLFW 3.4, or manually install a compatible GLFW 3.4+ C library on version 2.7.0.
affects: 2.7.0
gotchaWhen distributing applications with tools like cx_Freeze or PyInstaller, `glfw` might struggle to locate the bundled GLFW shared library, especially on non-Windows platforms. While `glfw` has built-in search logic for frozen executables, custom setups might still fail.
fix
Explicitly set the `PYGLFW_LIBRARY` environment variable to the path of the GLFW shared library within your frozen executable's distribution, or ensure the library is placed in a location where `glfw`'s internal search mechanism can find it (e.g., next to the executable).
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'glfw'
The `glfw` (pyGLFW) Python package has not been installed in your current Python environment.
fix
Install the package using pip: `pip install glfw`
ImportError: Failed to load GLFW3 shared library.
The Python `glfw` wrapper is installed, but the underlying GLFW C library (glfw3.dll on Windows, libglfw.so.3 on Linux, libglfw.dylib on macOS) cannot be found by the system or is missing required dependencies.
fix
On Windows, ensure the correct Microsoft Visual C++ Redistributable is installed (e.g., VC 2012 for 64-bit Python). On Linux (Debian/Ubuntu), install the development package: `sudo apt-get install libglfw3 libglfw3-dev`. On macOS, ensure GLFW is installed (e.g., via Homebrew) or that the `PYGLFW_LIBRARY` environment variable points to the correct `.dylib` file. For all platforms, ensure the library is in a location where the system can find it (e.g., system PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or by setting `PYGLFW_LIBRARY`).
AttributeError: module 'glfw' has no attribute 'init'
You are attempting to call GLFW functions using the C API's camelCase naming convention (e.g., `glfwInit()`) instead of the Pythonic snake_case used by the `pyGLFW` wrapper (e.g., `glfw.init()`).
fix
Use the Pythonic naming conventions for `pyGLFW` functions. For example, replace `glfwInit()` with `glfw.init()` and `glfwCreateWindow()` with `glfw.create_window()`.
GLFWError: (65542) b'WGL: The driver does not appear to support OpenGL'
GLFW failed to create an OpenGL or Vulkan context, often because the graphics driver does not support the requested API, is outdated, or there's an issue with display server configuration (e.g., running over RDP or in a virtual machine without proper GPU passthrough). The error code `65542` (GLFW_API_UNAVAILABLE) indicates that GLFW could not find support for the requested API.
fix
Update your graphics drivers to the latest version. Ensure your system and GPU support the requested OpenGL/Vulkan version. If running in a virtual environment or over remote desktop, ensure that the display server and drivers are configured to allow OpenGL context creation. Try setting GLFW window hints for a different OpenGL version (e.g., `glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3); glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)`).
Upgrade
Version history
2.10.2latest on PyPI · released Jul 21, 2026
Audit
Dependencies
GLFW (C library)requiredglfw is a Python binding for the native GLFW C library. While pre-compiled shared libraries are often bundled in Python wheels for Windows, macOS, and Linux, manual installation of the GLFW C library may be required on some systems or for specific configurations (e.g., via system package manager like 'apt install libglfw3' or by compiling from source).
PyOpenGLoptionalCommonly used in conjunction with glfw for rendering, as glfw only handles windowing and input, not graphics rendering itself.
Agent activity
7 hits · last 30 days
node
6
Resources
glfw — pip install glfw · libregistry