Custom built KiCAD 7.0.1 has no python console shown up

To develop KiCAD I cloned and built KiCAD (with 7.0.1 tag) under Debian 11.
But when I ran pcbnew, the python console showed up blank window.

I built kicad with wxWidgets 3.2 from codelite repo, and use python’s virtual env to install wxPython 4.2.

I configure build system by following command

cmake -G Ninja -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/debug_install -DPYTHON_SITE_PACKAGE_PATH=$(dirname $PWD)/debug_install/lib/python3/site-packages -DCMAKE_BUILD_TYPE=Debug ../../
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- KiCad install dir: <ROOT/kicad/build/debug_install>
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for iso646.h
-- Looking for iso646.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strncasecmp
-- Looking for strncasecmp - found
-- Looking for strtok_r
-- Looking for strtok_r - found
-- Looking for malloc
-- Looking for malloc - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for C++ include cmath
-- Looking for C++ include cmath - found
-- Looking for asinh
-- Looking for asinh - found
-- Looking for acosh
-- Looking for acosh - found
-- Looking for atanh
-- Looking for atanh - found
-- Performing Test HAVE_CMATH_ISINF
-- Performing Test HAVE_CMATH_ISINF - Success
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for getc_unlocked
-- Looking for getc_unlocked - found
-- Performing Test COMPILER_SUPPORTS_WSUGGEST_OVERRIDE
-- Performing Test COMPILER_SUPPORTS_WSUGGEST_OVERRIDE - Success
-- Enabling warning -Wsuggest-override
-- Performing Test COMPILER_SUPPORTS_WINCONSISTENT_MISSING_OVERRIDE
-- Performing Test COMPILER_SUPPORTS_WINCONSISTENT_MISSING_OVERRIDE - Failed
-- Performing Test COMPILER_SUPPORTS_WDUPLICATED_BRANCHES
-- Performing Test COMPILER_SUPPORTS_WDUPLICATED_BRANCHES - Success
-- Enabling warning -Wduplicated-branches
-- Performing Test COMPILER_SUPPORTS_WDUPLICATED_COND
-- Performing Test COMPILER_SUPPORTS_WDUPLICATED_COND - Success
-- Enabling warning -Wduplicated-cond
-- Performing Test COMPILER_SUPPORTS_WVLA
-- Performing Test COMPILER_SUPPORTS_WVLA - Success
-- Enabling error for -Wvla
-- Performing Test COMPILER_SUPPORTS_WIMPLICIT_FALLTHROUGH
-- Performing Test COMPILER_SUPPORTS_WIMPLICIT_FALLTHROUGH - Success
-- Enabling warning -Wimplicit-fallthrough
-- Performing Test COMPILER_SUPPORTS_WRETURN_TYPE
-- Performing Test COMPILER_SUPPORTS_WRETURN_TYPE - Success
-- Enabling error for -Wreturn-type
-- Performing Test COMPILER_SUPPORTS_WSHADOW
-- Performing Test COMPILER_SUPPORTS_WSHADOW - Success
-- Enabling warning -Wshadow
-- Performing Test COMPILER_SUPPORTS_WSIGN
-- Performing Test COMPILER_SUPPORTS_WSIGN - Success
-- Enabling warning -Wsign-compare
-- Performing Test COMPILER_SUPPORTS_WMISSING_INIT
-- Performing Test COMPILER_SUPPORTS_WMISSING_INIT - Success
-- Enabling warning -Wmissing-field-initializers
-- Performing Test COMPILER_SUPPORTS_WEMPTY_BODY
-- Performing Test COMPILER_SUPPORTS_WEMPTY_BODY - Success
-- Enabling warning -Wempty-body
-- Performing Test COMPILER_SUPPORTS_WREORDER
-- Performing Test COMPILER_SUPPORTS_WREORDER - Success
-- Enabling warning -Wreorder
-- Performing Test COMPILER_SUPPORTS_WMISMATCHED_TAGS
-- Performing Test COMPILER_SUPPORTS_WMISMATCHED_TAGS - Success
-- Enabling warning -Wmismatched-tags
-- Performing Test COMPILER_SUPPORTS_WIMPLICIT_FLOAT_CONVERSION
-- Performing Test COMPILER_SUPPORTS_WIMPLICIT_FLOAT_CONVERSION - Failed
-- Performing Test COMPILER_SUPPORTS_WPSABI
-- Performing Test COMPILER_SUPPORTS_WPSABI - Success
-- Disabling warning -Wpsabi
-- Configuring KiCad for the wxGLCanvas EGL backend
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found OpenGL EGL library: /usr/lib/x86_64-linux-gnu/libEGL.so
-- Found GLM: /usr/include (found suitable version "0.9.9.8", minimum required is "0.9.8")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Check for installed ZLIB -- found
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.74.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'cairo'
--   Found cairo, version 1.16.0
-- Found Cairo: /usr/lib/x86_64-linux-gnu/libcairo.so (found suitable version "1.16.0", minimum required is "1.12")
-- Checking for module 'pixman-1'
--   Found pixman-1, version 0.40.0
-- Found Pixman: /usr/lib/x86_64-linux-gnu/libpixman-1.so (found suitable version "0.40.0", minimum required is "0.30")
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found suitable version "1.74.0", minimum required is "1.71.0")
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "2.10.4")
-- Found the following HarfBuzz libraries:
--  HarfBuzz (required): /usr/lib/x86_64-linux-gnu/libharfbuzz.so
-- Found HarfBuzz: /usr/include/harfbuzz (found version "2.7.4")
-- Found Fontconfig: /usr/lib/x86_64-linux-gnu/libfontconfig.so (found version "2.13.1")
-- Checking for module 'ngspice'
--   Found ngspice, version 34
-- Found ngspice: /usr/include
-- Found OCC: /usr/include/opencascade (found version "7.5.1")
-- Found OpenCASCADE Standard Edition version: 7.5.1
--  ++ OpenCASCADE Standard Edition include directory: /usr/include/opencascade
--  ++ OpenCASCADE Standard Edition shared libraries directory: /usr/lib/x86_64-linux-gnu
-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2", minimum required is "4.0")
-- Found PythonInterp: ROOT/kicad/venv/bin/python3 (found suitable version "3.9.2", minimum required is "3.6")
-- Check for installed Python Interpreter -- found
-- Python module install path: ROOT/kicad/build/debug_install/lib/python3/site-packages
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.9.so (found suitable version "3.9.2", minimum required is "3.6")
-- pybind11 v2.9.2
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.9.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Found wxPython Phoenix 4.2.0/gtk3 (wxWidgets 3.2.0)
-- Found wxWidgets: -L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk3u_unofficial_gl-3.2;-lwx_gtk3u_unofficial_aui-3.2;-lwx_gtk3u_unofficial_html-3.2;-lwx_gtk3u_unofficial_core-3.2;-lwx_baseu_unofficial_net-3.2;-lwx_baseu_unofficial-3.2;-lwx_gtk3u_unofficial_propgrid-3.2;-lwx_baseu_unofficial_xml-3.2;-lwx_gtk3u_unofficial_stc-3.2;-lwx_gtk3u_unofficial_richtext-3.2 (found suitable version "3.2.0.1", minimum required is "3.2.0")
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.1") found components: doxygen dot
-- Found UnixCommands: /usr/bin/bash
CMake Warning (dev) at thirdparty/argparse/CMakeLists.txt:10 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'ARGPARSE_INSTALL'.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Module support is disabled.
-- Version: 9.0.0
-- Build type: Debug
-- CXX_STANDARD: 17
-- Performing Test has_std_17_flag
-- Performing Test has_std_17_flag - Success
-- Performing Test has_std_1z_flag
-- Performing Test has_std_1z_flag - Success
-- Required features: cxx_variadic_templates
-- nanodbc version: 2.14.0
-- nanodbc compile: C++14
-- nanodbc feature: ODBC Version Override - OFF
-- nanodbc feature: Disable async features - OFF
-- nanodbc feature: Enable Unicode - ON
-- nanodbc feature: Enable Boost - ON
-- nanodbc feature: Enable SQL_NO_DATA bug workaround - OFF
-- nanodbc build: ODBC on Unix - unixODBC
-- ODBC compile flags: -I/usr/include -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8
-- ODBC link flags:
-- Checking for module 'gtk+-3.0'
--   Found gtk+-3.0, version 3.24.24
-- S3DSG version: 2.0.0
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: unit_test_framework filesystem system
-- Found wxWidgets: -L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk3u_unofficial_gl-3.2;-lwx_gtk3u_unofficial_aui-3.2;-lwx_gtk3u_unofficial_html-3.2;-lwx_gtk3u_unofficial_core-3.2;-lwx_baseu_unofficial_net-3.2;-lwx_baseu_unofficial-3.2;-lwx_baseu_unofficial_xml-3.2;-lwx_gtk3u_unofficial_stc-3.2 (found suitable version "3.2.0.1", minimum required is "3.0.0")
-- Configuring done
-- Generating done
-- Build files have been written to: ROOT/kicad/build/t

I ran the pcbnew via KICAD_RUN_FROM_BUILD_DIR=1 ./pcbnew/pcbnew

That’s not going to work.

You see it finds system wxpython which is compiled with very old wxwidgets. On debian 11 you have to compile (or get somewhere) both wxwidgets and wxpthon with matching versions.

Hello, thanks for reply.

It actually works, but when I generated this example config I forgot to execute . venv/bin/activate, after regenerated it I only fix lines in pasted config and missed this line.

I have re-ran the cmake and pasted it again. it actually found the wxpython 4.2

And if the cmake find wxWidgets before 3.2 (as shown in old cmake run) the pcbnew will popup that it will not support python console while using wxWidgets lower than 3.2

You are highly likely to run into issues running kicad even if it compiles.
Wxpython is very picky about being compiled exactly with the same exact version of wxwidgets that it is running with. wxpython installed from pip will likely not match the version of wxwidgets you have.

Also you will have to run kicad from virtualenv activated shell every time. Why bother when you can just install wxpython into system properly.

I want to do develop, I need to run it locally without installing , especially avoid sudo to install

Well, try it your way, maybe you will not have issues with what you are trying to do. Otherwise you know how to fix it, you will only have to install wxpython once, same as any other library needed for kicad.

Also if what you are going to work on is not related to python scripting you can disable that feature in cmake.

the problem should not be the virtual env, because I did install wxpython in global python env before it is the same issue

Yes, like I said, the problem is likely mismatch of wxpython and wxwidgets versions. You can’t expect them to match when you install wxpython from pip, doesn’t matter if it’s into global site-packages or into virtualenv.

1 Like

Yes you are right

But how a Kicad developer will do with it? I should just use the wx installed along with wxPython instead ?

I used:

cmake -G Ninja -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/debug_install -DwxWidgets_CONFIG_OPTIONS="--prefix=$PWD/../../venv/lib/python3.9/site-packages/wx" -DPYTHON_SITE_PACKAGE_PATH=$(dirname $PWD)/debug_install/lib/python3/site-packages -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS=-B/usr/local/libexec/mold ../../

to build with wx installed along with wxPython, but failed with:

-- Found OpenCASCADE Standard Edition version: 7.5.1
--  ++ OpenCASCADE Standard Edition include directory: /usr/include/opencascade
--  ++ OpenCASCADE Standard Edition shared libraries directory: /usr/lib/x86_64-linux-gnu
-- Found SWIG: /usr/bin/swig4.0 (found suitable version "4.0.2", minimum required is "4.0")
-- Found PythonInterp: /home/hongbo/Developer/Engineering/kicad/venv/bin/python3 (found suitable version "3.9.2", minimum required is "3.6")
-- Check for installed Python Interpreter -- found
-- Python module install path: /home/hongbo/Developer/Engineering/kicad/build/debug_install/lib/python3/site-packages
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.9.so (found suitable version "3.9.2", minimum required is "3.6")
-- pybind11 v2.9.2
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.9.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Found wxPython Phoenix 4.2.0/gtk3 (wxWidgets 3.2.0)
CMake Error at cmake/FindwxWidgets.cmake:922 (message):
  wxWidgets wx/version.h file not found in
  /home/hongbo/Developer/Engineering/kicad/build/debug_7.0.5/../../venv/lib/python3.9/site-packages/wx/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2-unofficial;/home/hongbo/Developer/Engineering/kicad/build/debug_7.0.5/../../venv/lib/python3.9/site-packages/wx/include/wx-3.2-unofficial.
Call Stack (most recent call first):
  CMakeLists.txt:947 (find_package)


-- Configuring incomplete, errors occurred!

I think I misunderstood wxwidgets and wxPython. So wxPython has a bundled runtime of wxwidgets, and I need to build Kicad with that wxwidgets inside wxPython. But the wxwidgets installed along with wxPython has no version.h, I think I’d better to build the whole wxPython by myself instead ?

Is this a preferable way ?

If an include file is missing for package foo, it’s usually because you need to install the foo-dev package.

The problem is this:

I am using Debian 11, with no wx3.2 in official repo.

So I can use wx3.2 from codelite apt repo as specified from wxWidgets official homepage.

But there is no wxPython package inside codelite, I have to install wxPython from pip, but as noted before, I should use wx3.2 bundled along with wxPython, but there is only runtime lib, no headers. Unless I need to specify kicad to search version.h along with wx3.2 from codelite repo ? oh I rebuilt wxPython from source code.

You might want to retry with 7.0.5 and Debian 12. But travails like you’ve experienced are not unexpected as KiCad depends on recent fixes in the wx family of packages.

Only wxpython from pip has bundled wxwidgets and it doesn’t come with headers, as you have found out.

Preferable way is to use native system packages of both wxpython and wxwidgets and native system headers for wxwidgets, then you are guaranteed to have them be compatible. If your system’s packages are old then see if there are newer ones in backports.
I recommend you upgrade to debian 12, I did and it was smooth for me.

Otherwise get rid of your venv, uninstall all wx* packages from your system, grab fresh wxpython sources and compile them, if I am not mistaken the build process automatically pulls correct wxwidgets sources and compiles them too. But if not, then compile matching wxwidgets yourself and point wxpython to it.

Kicad devs don’t do development on unsupported systems.

Thanks !

I have understood my problem.

I am just a bit fear upgrade may break my current system.

I’ll try to upgrade system a few days later after I got back to home.

Is there a list of development System supported by KiCad ?

I think eelik used to keep a list of instructions for various distros. In principle any Linux distro that has a C++ compiler should be able to serve as a base.

Autocorrect keeps changing distro to disaster. :rofl:

I finally got my Python Console to work!

For others may encounter this problem, I leave some notes here.

As discuss above, wxPython needs to use exactly same version wxWidgets. The pip-installed wxPython has wxWidgets bundled, whereas that wxWidgets has only runtime libraries, no dev headers. As a result I’d rebuild wxPython from source code.

Because I am using Debian 11, who is only shipping wx3.0, I installed wx3.2.1 ( required by wxPython 4.2.1 ) from codelite repo. And download wxPython (4.2.1 in my case) from pypi.

For building KiCad, I used venv to install all python related libraries. So all following instructions are operated under the activated virtual environment.

Decompress tarball to wxPython-4.2.1, and build with:

python build.py  --use_syswx build_py

If you are missing some wxWidgets libraries, install them ( -dev, webview and media in my case ), then build again until succeeded.

Then install it by:

python build.py  --use_syswx install_py

Finally, rebuild KiCad with:

cmake -G Ninja -DKICAD_VERSION_EXTRA="your-custom-ver" -DKICAD_USE_EGL=ON -DCMAKE_INSTALL_PREFIX=$(dirname $PWD)/debug_install -DPYTHON_SITE_PACKAGE_PATH=$(dirname $PWD)/debug_install/lib/python3/site-packages -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS=-B/usr/local/libexec/mold ../../

And run inside build directory by:

KICAD_RUN_FROM_BUILD_DIR=1 ./kicad/kicad

or

KICAD_RUN_FROM_BUILD_DIR=1 ./pcbnew/pcbnew
3 Likes

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