wgpu
raw JSON → 0.31.0 verified Fri May 01 auth: no python
WebGPU for Python: a Python implementation of the WebGPU API, enabling modern GPU compute and rendering on multiple backends (Vulkan, Metal, D3D12, OpenGL). Current version 0.31.0. Requires Python >=3.10. Releases roughly monthly.
pip install wgpu Common errors
error ModuleNotFoundError: No module named 'wgpu.backend' ↓
cause Importing from `wgpu.backend` which was removed in v0.10.0.
fix
Use
import wgpu and call wgpu.request_adapter() instead. error AttributeError: module 'wgpu' has no attribute 'create_device_with_swap_chain' ↓
cause API changed; `create_device_with_swap_chain` was removed in favor of `request_adapter` + `request_device`.
fix
Use
adapter = wgpu.request_adapter(...) then device = adapter.request_device(...). error wgpu.gui.glfw.GlfwCanvas not found (import fails) ↓
cause GUI backends moved to `wgpu.gui.auto` or specific named modules like `wgpu.gui.glfw` may not be installed by default.
fix
Install extra dependencies:
pip install wgpu[gui] and use from wgpu.gui.auto import WgpuCanvas. Warnings
breaking Import path changed in v0.10.0: previously `import wgpu.backend.wgpu_native` is no longer needed; use `import wgpu` and call `wgpu.request_adapter()`. ↓
fix Replace `from wgpu.backend.wgpu_native import ...` with `import wgpu` and use `wgpu.request_adapter`.
breaking GUI canvas module restructured in v0.15.0: `from wgpu.gui import WgpuCanvas` no longer works; use `from wgpu.gui.auto import WgpuCanvas`. ↓
fix Change import to `from wgpu.gui.auto import WgpuCanvas`.
gotcha The `wgpu` library bundles wgpu-native binaries. On some platforms (e.g., Linux without Vulkan drivers) it may fall back to OpenGL or silently fail. Test on target hardware. ↓
fix Install appropriate GPU drivers or test with `wgpu.request_adapter` to see available adapters.
Imports
- request_adapter wrong
import wgpu.backend.wgpu_nativecorrectfrom wgpu import request_adapter - GUI wrong
from wgpu.gui import WgpuCanvascorrectfrom wgpu.gui.auto import WgpuCanvas
Quickstart
import wgpu
import wgpu.backends.wgpu_native # triggers auto backend selection
adapter = wgpu.request_adapter(canvas=None, power_preference="high-performance")
device = adapter.request_device(required_features=[])
print(f"Adapter: {adapter.summary}")
print(f"Device: {device.summary}")