From 1a14a45881fe90acfdef9bca67af2e19d470fb4e Mon Sep 17 00:00:00 2001 From: TE603 Date: Wed, 22 Apr 2026 16:00:43 +0900 Subject: [PATCH] fix(windows): add KiCad 10.0 bin/Lib/site-packages to Python path detection KiCad 10.0 on Windows ships pcbnew.py under bin/Lib/site-packages rather than the lib/python3/dist-packages path used by KiCad 9.x. Without this path the MCP server's Python process fails to import pcbnew and exits immediately with "Failed to import pcbnew module - KiCAD Python API not found". Changes: - Prioritise 10.0 in the version list so the newer path is checked first - Add bin/Lib/site-packages check before the existing lib/python3/dist-packages check for every version, so both layouts are supported side-by-side Note: the pcbnew extension is compiled against KiCad's bundled Python 3.11, so callers must also set KICAD_PYTHON to the KiCad python.exe (C:\Program Files\KiCad\10.0\bin\python.exe) to avoid a DLL version conflict when the system Python differs. Co-Authored-By: Claude Sonnet 4.6 --- python/utils/platform_helper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/utils/platform_helper.py b/python/utils/platform_helper.py index b014737..d6c61c1 100644 --- a/python/utils/platform_helper.py +++ b/python/utils/platform_helper.py @@ -59,7 +59,12 @@ class PlatformHelper: ] for pf in program_files: # Check multiple KiCAD versions - for version in ["9.0", "9.1", "10.0", "8.0"]: + for version in ["10.0", "9.0", "9.1", "8.0"]: + # KiCad 10.0+ Windows: bin/Lib/site-packages + path = pf / version / "bin" / "Lib" / "site-packages" + if path.exists(): + paths.append(path) + # KiCad 9.x Windows: lib/python3/dist-packages path = pf / version / "lib" / "python3" / "dist-packages" if path.exists(): paths.append(path)