devbisme / skidl

SKiDL is a module that extends Python with the ability to design electronic circuits.
https://devbisme.github.io/skidl/
MIT License
1.06k stars 120 forks source link

the function generate_pcb() can't generate PCB file #191

Open wofy-92 opened 1 year ago

wofy-92 commented 1 year ago

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

image

image

Desktop (please complete the following information):

tapegoji commented 10 months ago

did you fix this?

roboPanda69 commented 4 months ago

Hi @devbisme if this problem is not taken, could I solve this ?

devbisme commented 4 months ago

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.

roboPanda69 commented 4 months ago

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 -

  1. 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.
  2. 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")
  3. After this some might face an error for ImportError: DLL load failed while importing _pcbnew: The specified module could not be found.
  4. 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 ]
  5. 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
devbisme commented 3 months ago

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.