skidl
skidl copied to clipboard
the function generate_pcb() can't generate PCB file
Describe the bug
Hi devbisme, When I running the function generate_pcb(), I get a WARNING:
WARNING: kinet2pcb module is missing. Can't generate a KiCad PCB without it.
but I have installed kinet2pcb
** The test code in the JupyterLab**
from skidl import *
esp32 = Part('RF_Module','ESP32-WROOM-32', footprint='RF_Module:ESP32-WROOM-32')
generate_pcb()
** output message**
WARNING: kinet2pcb module is missing. Can't generate a KiCad PCB without it. @ [D:\Python310\Lib\site-packages\IPython\core\interactiveshell.py:3433=>C:\Users\Administrator\AppData\Local\Temp\ipykernel_29400\1868553726.py:4] INFO: 1 warnings found while creating PCB. INFO: 0 errors found while creating PCB.
Screenshots
Desktop (please complete the following information):
- Windows11
- Python3.10.0
- SKiDL1.2.1
- kinet2pcb1.1.0
did you fix this?
Hi @devbisme if this problem is not taken, could I solve this ?
I'm not seeing this error when running the tests on linux. You can try it on Windows and see if the error occurs there. If so, then go ahead and attempt a fix. Please use the version1 branch to make your fix. I added a test for generate_pcb() to test_generate.py, so make sure to fetch your branch to get that change.
If you don't see any errors, then I can close this issue.
Hi Dave, the problem was majorly for Windows user. We have to include the pcbnew module in our Python library search path in the code of kinet2pcb.py.
I am writing instructions on how one could change the same for beginners using the code for the first time -
- Open kinet2pcb.py file (inside kinet2pcb folder), in line 15 we have
sys.path.append('/usr/lib/python3/dist-packages'), here we have to change this path so that it could locate pcbnew.py file. - For KiCAD 8.0 the default path is "C:/Program Files/KiCad/8.0/bin/Lib/site-packages", so in the code we have to change line 15 of kicad.py to
sys.path.append("C:\\Program Files\\KiCad\\8.0\\bin\\Lib\\site-packages") - After this some might face an error for
ImportError: DLL load failed while importing _pcbnew: The specified module could not be found. - To solve the above problem we have to Copy _pcbnew.pyd from the sites-packages folder to the KiCad/bin folder. [ For reference - https://forum.kicad.info/t/cannot-import-pcbnew-when-running-kicad-bin-python-exe-on-the-command-line/14519/15?u=prashun_pandey ]
- We have to add
sys.path.append("C:\\Program Files\\KiCad\\8.0\\bin\\")at line 14. And then our program would work perfectly.
Here is how code looked before -
from past.builtins import basestring
import argparse
import logging
import os
import os.path
import re
import shutil
import sys
import kinparse
sys.path.append('/usr/lib/python3/dist-packages')
import pcbnew
import hierplace
For Windows user they have to change as -
from past.builtins import basestring
import argparse
import logging
import os
import os.path
import re
import shutil
import sys
import platform
import kinparse
sys.path.append("C:\\Program Files\\KiCad\\8.0\\bin\\")
sys.path.append("C:\\Program Files\\KiCad\\8.0\\bin\\Lib\\site-packages")
import pcbnew
import hierplace
Thanks for looking at this, @roboPanda69. It appears that the changes need to be made to the kinet2pcb utility, so I'll do that over there. Then I'll come back and close this issue.