kicad-panelizer
kicad-panelizer copied to clipboard
ModuleNotFoundError: No module named 'pcbnew'
OS: Win 10 KiCad version: 5.1.4 Python 3 installed.
When I try to run the script with ./panelizer.py --panelx=100 --panely=100 /path/to/source_board.kicad_pcb
, i the the error from the title:
Traceback (most recent call last):
File "...\panelizer.py", line 6, in <module>
import pcbnew
ModuleNotFoundError: No module named 'pcbnew'
Any insight into what I'm missing?
EDIT: I added the full command output.
not tried on windows but suspect you don't have the python pcbnew module installed, seems to be a few issues on google e.g. https://forum.kicad.info/t/running-kicad-python-scripts-on-windows/11465/3 so probably an environment issue rather than panelizer one
Well, crap. I was hoping that someone smarter than me knew how to fix this. It doesn't seem like it's easy or even possible, at least with my experience of installing KiCad a few days ago and Python yesterday.
Yeah my experience too. Seems kicad-5.1 ships with an old Python 2.7 pcbnew module, on Linux at least. Anybody know if there is a Python 3 pcbnew module somewhere, or will that not work because it needs to be integrated with Kicad?
Edit: I found a workaround. Run the Python pasteurizer script like this:
pasteurizer -w panelizer.py
This will convert the Python 3 code into Python 2 code by adding imports of the future modules. Then edit the top of the file to say #!/usr/bin/env python2 (instead of 3).
Now you can run it as a Python 2 script.
I wish the Kicad devs would switch over to Python 3 now that 2 is out of support.
had a bit of a play with this, and if i use the workarounds from pasteurizer, then it no longer works with python3 (as you'd need python2 versions of all the libs) but should work for windows then as kicad installs python2.
conversely you can't install python3 on windows and expect this to work as you don't have python3 versions of the libraries like wxpython, pcbnew etc. as kicad aren't shipping python3 builds for windows.
given that debian, arch, ubuntu, gentoo (i believe fedora/suse too) and even kicad's own PPA for mint all use python3, i can't even figure out how people are triggering this error on linux.
My Kicad package is slightly behind at 5.1.5. I expect I'll get Py3 when I upgrade. Devs are working on getting Py3 to work on Windows so hopefully this will be a workaround of the past some day.
closing as kicad is now 2 major versions newer