Where is the updated documentation about Python scripting

I’m using Kicad 9 under Linux but I find only outdated tutorials or articles about Python scripting.
Looking for an official documentation I found this:

https://docs.kicad.org/kicad-python-main/kicad.html

but it just lists the API members, saying nothing about how to install, configure the interpreter and invoke the scripts?
Where can I find an up-to-date documentation on this topic?

Maybe you want to check out this post: KiCad 9.0 Python API (IPC API)

The API is very new to KiCad 9, the documentation is kind of there, but it is hard to get started. But you don’t have to install anything, python is shipped with KiCad.

Also it is worthy to note that the new API has still quite a few bugs in it. So if something isn’t working it might not be your fault. The basics are working though. But I paused the development of my plugin until they are fixed.

There are also examples: examples · main · KiCad / KiCad Source Code / KiCad API Python Bindings · GitLab

1 Like

Maybe my open PR with the update to new API is also helpful to you: Update to IPC Python API by TimGoll · Pull Request #17 · DIaLOGIKa-GmbH/kicad-coil-creator · GitHub

Thanks, I’m reading through the whole post. Still there is something I don’t get.
You said:

you don’t have to install anything

but in that thread several people talk about kicad-python repository: should I ignore it?
Anyway, I enabled the API and detected the interpreter as others have done:

when I try to run the hello.py example script I get the usual error:

$ ./hello.py 
Traceback (most recent call last):
  File "/home/marcotrapanese/Scaricati/./hello.py", line 23, in <module>
    from kipy import KiCad
ModuleNotFoundError: No module named 'kipy'

I’m aware this is the first question in the thread you linked, but honestly I cannot find a clear explanation of what I’m missing.

do you have a requirements.txt? You have to put this line it it:

kicad-python >= 0.3
1 Like

Ok, so some configuration is needed :sweat_smile:
Anyway, even putting a configuration.txt with that content in the same folder of hello.py changes nothing.

configuration? You don’t need a configuration file.

For an addon that can be launched via a button in the UI, you need the following: kicad-coil-creator/plugins at kicad9 · DIaLOGIKa-GmbH/kicad-coil-creator · GitHub

You can ignore the subfolders, they only contain the logic for my addon

1 Like

Sorry, for “configuration” I mean something to do before I can run a script. In this case the requirements.txt file (and it seems not enough, though).

I don’t want to create an addon, I’m just trying to write my own Python scripts to edit my schematics and layouts.

FYI, the API is not yet compatible with schematics, only with the PCB editor for now.

1 Like

kicad-skip is a Python package for manipulating KiCad schematic and layout files.

2 Likes

Python is installed by default on all of the major Linux distros. It would be surprising to me if KiCad installed yet another Python interpreter on Linux, but I haven’t installed v9 yet.

You’re absolutely right, I was speaking from a windows point of view. That being said I read somewhere that snap packages ship their own python version