How to use Python interface for Nightly builds?

Could someone explain how to use the Python interface using a KiCad Nightly build?
Since the KiCad binaries have the -nightly postfix I’m not able to import pcbnew anymore. As soon as the KiCad release version is installed it works fine but I’d like to check a few scripts using the Nightly version to make sure everything runs fine.
I already checked if I’ve to import something like pcbnew-nightly but non if it is available.

Out of curiosity, where on the system am I able to find the Python interface? I printed the import paths from the Python console and couldn’t find any KiCad related in any path.

Thanks for you support!

Post full KiCad version information.

Tested with latest Nightly build and Stable 5.0.2 from APT sources on Ubuntu 18.04 system.

That is not full version information, I’m talking about text that appears in Help->About Kicad->Show Version Info

That includes compile flags that will tell if version you have is compiled with python support and if it’s py2 or py3.

5.0.2 on Linux doesn’t have python support, nightly should have.

Sorry, I wasn’t aware of this. Is there any way to receive this information on the console without a window manager? We’ve KiCad running headless on a server installation.

You can always use something like xpra with xvfb to launch fake X session and connect to it, run kicad there. I don’t know if it’s possible to do from console only.

But if you specify exactly which repo you got your nightly from and what is the version info of the package that should be enough.

I used the “official” repos from https://kicad.org/download/ubuntu/

ppa:js-reynaud/kicad-5.1

and

ppa:js-reynaud/kicad-dev-nightly

for nightly builds

If you used kicad-5.1 ppa you wouldn’t have ended up with 5.0.2.
Anyway, both of those repositories provide packages with python support. Just make sure to use python3, not python2. pcbnew module will be installed in python3 dist-packages.

this should be useful:

#if defined(__WXGTK__)
            "/usr/share/kicad/plugins",
            "/usr/local/share/kicad/plugins",
#elif defined(__WXMSW__)
            wxString::Format( "%s\\scripting\\plugins", Pgm().GetExecutablePath() ),
#elif defined(__WXMAC__)
            wxString::Format( "%s/plugins", GetOSXKicadDataDir() ),
#endif

@qu1ck your’re right, I actually installed 5.1.2 from the PPA not 5.0.2
Anyway, still working on getting the nightly running

It looks like the nightly from js-reynaud/kicad-dev-nightly does not install any Python packages. Thanks for the hint to use Python 3. I checked everything using Python 3 now.
Steps to reproduce

  • Install latest KiCad nightly from js-reynaud/kicad-dev-nightly
  • Run python3 console
  • Type import pcbnew
  • Hit enter
    Result should be ModuleNotFoundError: No module named 'pcbnew'

ls /usr/lib/python3/dist-packages also contains no KiCad / Pcbnew packages.

@jsreynaud are nightlies not built with scripting?

@aisler you may have to build kicad yourself if that’s the case.

There are 2 nightly ppa versions for ubuntu systems :

  • Dev version, nightly of the future version 6
  • 5.1 version, nightly of the 5.1 version that overwrites stable 5.1.2. At this moment is v5.1.3

@pedro could you tell me which PPA to use for the nightly version of 5.1.3?

Sure, Patrick

Could you tell me the version of Ubuntu you use. Because some of them don’t compile with python support (As I remember 18.10 and 19.04)

Sure, right now we’re on Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-54-generic x86_64)

Not at this time (see: https://bugs.launchpad.net/kicad/+bug/1815349)

Are you trying to import in a generic console, not from inside KiCad? The module is in /usr/lib/kicad-nightly/lib/python3/dist-packages/ which apparently isn’t in the search path of python3. You can add it with:

import sys
sys.path.insert(1, '/usr/lib/kicad-nightly/lib/python3/dist-packages/')
2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.