Installation & build

Installing KiCad and using its Python API (GUI, console, headless)

Set up KiCad's Python API: run scripts in the console or headless, fix “No module named 'pcbnew'”, and compare pcbnew with the IPC API.

4 minpcbnew + IPC

Loading a board and inventorying it in one pass with pcbnew's Python API

Load a .kicad_pcb file and list footprints, zones, tracks, vias, text, and nets in a single pass, by script — with pcbnew or KiCad's IPC API.

2 minpcbnew + IPC

Resolving a layer name to an ID by script with pcbnew's Python API

Convert a layer name ("F.Cu", "B.SilkS"...) into a numeric ID by script, and back again, with pcbnew or KiCad's IPC API — and the pitfalls on both sides.

2 minpcbnew + IPC

Creating a new net by script and assigning it with KiCad's Python API

Create a net that doesn't exist yet on the board and assign it to a via or a pad — with the tested trap that silently drops it.

3 minpcbnew + IPC

Rotating a position around an arbitrary center with KiCad's Python API

Compute a point's new position after rotating around any center — the base building block for array or panel placement, with pcbnew or the IPC API.

3 minpcbnew + IPC

Fix “ModuleNotFoundError: No module named 'pcbnew'” in KiCad Python

Why import pcbnew fails outside KiCad, and 4 fixes tested on KiCad 10: bundled Python, KiCad Command Prompt, venv, IPC API.

3 min

Enabling KiCad's IPC API and checking that Python connects

Tick “Enable KiCad API”, install kicad-python and test the connection in 6 lines. The “Connection refused” error explained, tested on KiCad 10.

1 min

Headless KiCad: Python scripts and kicad-cli without the GUI

Edit a board, run DRC and export Gerber and drill files without opening KiCad: headless pcbnew, kicad-cli, and exit codes for CI pipelines.

2 minpcbnew + IPC

Migrating your pcbnew scripts to the IPC API before KiCad 11

pcbnew is being removed in KiCad 11: a pcbnew → kipy mapping table, the key differences, and a method to port your KiCad Python scripts.

3 min