Anyone installed NumPy for use with KiCAD's python?


Does anyone have instructions on how to install NumPy for use in KiCAD?


numpy is a python package so you should use your python package manager to install it and then import it into your python source with e.g. import numpy as np

Perhaps have a look here as a start:


Thank you joost! It’s a little more complicated with NumPy because of the compiling requirements. I have also already attempted the install within KiCAD python a while ago, but didn’t succeed.

I will try again soon, but was wanting to know if anyone has a tested successful method for KiCAD. on windows especially, but also for other platforms to determine if I can distribute KiCAD python scripts dependent on NumPy with some reasonable assurance that others, including non-programmers, could easily use.


Hmm, you should not have to compile numpy unless you got the actual fortran/c code set and want to do this all yourself. But I guess you go through all that. Not sure what you meant by “install within KiCAD python”.

In general, you can call python sources from KiCAD and KiCAD places no conditions or restrictions on the modules you include e.g. numpy or other modules. I am on a OS X machine so is a bit easier/more natural for me but on Windows it should not be different.

Curious, what are you doing that requires numpy?


“KiCAD’s python” is the python 2.7 installed in the KiCAD installation directories.

The problem with installing NumPy is that I get “not supported on this platform” when I try to install it from a variety of whl files. When installing from pip directly, I get errors that look like failure to compile.

I’m creating a few functions for checking pads, silkscreen, stencils, and drill/via holes.

I’m documenting progress here on what I’m now calling KiPadCheck

I’ve been getting good performance on basic checks for pads. DRC for hole to track spacing takes a little longer, but still reasonable (10 seconds) on my 75mm x 75mm board. I’m now starting to code non-orthogonal rectangular checks (mask (*edit: was silk) to rotated text). There really are no algorithms for that specifically, but intersection of convex polygons is the closest step up. Since the calculations will start to take longer if larger board, and especially tracks are being used, then I thought it would be prudent to install a numerical library. Another alternative is shapely, which has whl files available as well, but it also is a binary whl, similar to NumPy.


Some detail here


Ah, extended DRC - a noble task! I’d be interested in poking through your code and wouldn’t mind adding functionality - do you have it up on github yet? I understand your need for numpy now. I am on OS X so there is no “KiCAD python”. OS X comes with 2.7 installed for legacy software - python 3.6 is the current release. I don’t know how things are on MSWindows but I would advice you to install Python3.6 so you have the most relevant code base and can use pip, home-brew or whatever other installer you need without having to fudz with fortran compilers to get numpy installed.


I’ll be happy to share soon. I don’t have github set up yet. Is there a way to share on github without using git locally? I would be uploading a single file.

I’m still in the process of extending it to be able to detect intersection of polygons primarily (right now) for mask check vs. silkscreen rotated text.

And a few admin tasks before I share:

  1. conform to python naming conventions in PEP8,
  2. refactor to move my “point” class (which includes add, sub, dot, distance, distance2 (squared), and projection functions) outside of the KiPadCheck class.
  3. rework to fix reentrance and menu functions, which I messed up during my attempt to include Action Plugin support. I’ve learned that 4.07 will not include action plugin (according to my question on the developer’s list), but it still is confusing since the pcbnew object in my 4.06 has an ActionPlugin object with “register” and “deregister” attributes.


Github would be set up as a remote to your local repo. So you’ll need to your source to your local git first which is quite easy to do (in your folder where the sources are type “git init”, followed by a “git add” to add the sources, finally a “git commit”). Then you add a remote to your local repo - the remote being github. Adding remotes is done with “git remote add ‘details’” With ‘details’ your connection details. There are a ton of tutorial pages, have a look at this one:

I’d be interested when you put it up on github, lemme know when you do. I only code in python3 and up so may add that version support if it makes sense.


KiCAD seems to support only 2.7, as that is what is built in (at least on Windows). I’m confused by your statement the KiCAD on MacOS uses the already installed python, and not a “custom” python install within the KiCAD installation directory. There seems to be an ongoing project to get KiCAD to support Python3. So I’m assuming that KiCAD does not support Python3 at the moment. What am I not unders tanding? (sorry for the newb question).

In any case, I’m making good progress on intersecting polygon. I think it’s working. However, my identification of exact pad bounding box is getting ‘confused’ by orientation.

Note the highlighted pads are correctly identified as having silk screen over them (the large diagonal text). For testing, I’m creating the bounding boxes on Eco2.User layer to help identify errors in coding.


Ah, see what you mean. I only made a few python scripts which deal with net lists and such so didn’t need the kicad API. Macs normally have Python2.7 installed from the get go so I don’t think KiCAD install on the mac includes the python distro.

Which kicad API do you work with? This one?

How do you specify your DRC rules, in a separate (text) file I hope?


I’d be surprised if the KiCad installation on a Mac doesn’t include Python. But maybe that’s true (anyone else comment?).

I also have several versions of Python installed on my Windows 7 box (2.3, 2.7, 3.5, 3.6). KiCad is definitely using the version in it’s installation directory (KiCad\bin\python.exe).

I’m using that came with my KiCad install. I’m not sure exactly how to identify the documentation for it, but I’ve been using this as a reference. It seems to be close to what I’m using.

The rules will be specified eventually by this project, which I will continue to develop as KiPadCheck gets to certain maturity level. At first, however, the rules will be specified by a simple interface similar to: