Can't open scripting console of KiCad 5.1.5 under Ubuntu

This is my kicad and system version


When I click the scripting console button, I get an error

**error:unable to create the Python Console**

Case of my python and module

XXX@X-U:~$ python -V
Python 2.7.17

/////////////////////////////////////////
>>> help("modules");

Please wait a moment while I gather a list of all available modules...

DEBUG:pip.utils:lzma module is not available
DEBUG:pip.vcs:Registered VCS backend: git
DEBUG:pip.vcs:Registered VCS backend: hg
DEBUG:pip.vcs:Registered VCS backend: svn
DEBUG:pip.vcs:Registered VCS backend: bzr
BaseHTTPServer      audioop             htmlentitydefs      sets
Bastion             axolotl             htmllib             setuptools
CDROM               axolotl_curve25519  httplib             sgmllib
CGIHTTPServer       base64              idna                sha
Canvas              bdb                 ihooks              shadowsocks
ConfigParser        binascii            imaplib             shelve
Cookie              binhex              imghdr              shlex
Crypto              bisect              imp                 shutil
DLFCN               bsddb               importlib           signal
Dialog              bz2                 imputil             signatures
DocXMLRPCServer     cPickle             inspect             sip
FileDialog          cProfile            io                  sipconfig
FixTk               cStringIO           ipaddress           sipconfig_nd
HTMLParser          cachecontrol        itertools           site
IN                  caches              json                sitecustomize
MimeWriter          cairo               keyring             six
Queue               calendar            keyrings            smtpd
ScrolledText        certifi             keyword             smtplib
SimpleDialog        cgi                 lib2to3             sndhdr
SimpleHTTPServer    cgitb               libsvn              socket
SimpleXMLRPCServer  chardet             libxml2             spwd
SocketServer        chunk               libxml2mod          sqlite3
StringIO            cmath               linecache           sre
TYPES               cmd                 linuxaudiodev       sre_compile
Tix                 code                locale              sre_constants
Tkconstants         codecs              logging             sre_parse
Tkdnd               codeop              lsb_release         ssl
Tkinter             collections         macpath             stat
UserDict            colorama            macurl2path         statvfs
UserList            colorsys            magic               string
UserString          command             mailbox             stringold
_LWPCookieJar       commands            mailcap             stringprep
_MozillaCookieJar   compileall          markupbase          strop
__builtin__         compiler            marshal             struct
__future__          contextlib          math                subprocess
_abcoll             contrib             md5                 sunau
_ast                cookielib           mhlib               sunaudio
_backport           copy                mimetools           svn
_bisect             copy_reg            mimetypes           symbol
_bsddb              crypt               mimify              symtable
_cffi_backend       cryptography        mmap                sys
_codecs             csv                 modulefinder        sysconfig
_codecs_cn          ctypes              multifile           syslog
_codecs_hk          curses              multiprocessing     tabnanny
_codecs_iso2022     datetime            mutex               talloc
_codecs_jp          dateutil            netrc               tarfile
_codecs_kr          dbhash              new                 telnetlib
_codecs_tw          dbm                 nis                 tempfile
_collections        dbus                nntplib             termios
_csv                decimal             ntpath              test
_ctypes             difflib             nturl2path          textwrap
_ctypes_test        dircache            numbers             this
_curses             dis                 opcode              thread
_curses_panel       distlib             operator            threading
_dbus_bindings      distro              optparse            time
_dbus_glib_bindings distutils           os                  timeit
_elementtree        doctest             os2emxpath          tkColorChooser
_functools          dot2tex             ossaudiodev         tkCommonDialog
_hashlib            drv_libxml2         packages            tkFileDialog
_heapq              dsextras            pango               tkFont
_hotshot            dumbdbm             pangocairo          tkMessageBox
_io                 dummy_thread        parser              tkSimpleDialog
_json               dummy_threading     pdb                 toaiff
_locale             easy_install        pickle              token
_lsprof             email               pickletools         tokenize
_md5                enchant             pip                 tool
_multibytecodec     encodings           pipes               trace
_multiprocessing    ensurepip           pkg_resources       traceback
_osx_support        enum                pkgutil             treeadapters
_pyio               errno               platform            treebuilders
_random             exceptions          plistlib            treewalkers
_sha                extern              popen2              ttk
_sha256             fcntl               poplib              tty
_sha512             filecmp             posix               turtle
_socket             fileinput           posixfile           types
_sqlite3            filters             posixpath           unicodedata
_sre                fnmatch             pprint              unittest
_ssl                fontforge           profile             urllib
_strptime           formatter           psMat               urllib2
_struct             fpformat            pstats              urllib3
_symtable           fractions           pty                 urlparse
_sysconfigdata      ftplib              pwd                 user
_sysconfigdata_d    functools           py_compile          util
_sysconfigdata_nd   future_builtins     pyclbr              uu
_testcapi           gc                  pydoc               uuid
_threading_local    gdbm                pydoc_data          warnings
_tkinter            gdbm_d              pyexpat             wave
_tkinter_d          genericpath         pygments            weakref
_trie               getopt              pygtk               webbrowser
_vendor             getpass             pygtkcompat         webencodings
_warnings           gettext             pyparsing           wheel
_weakref            gi                  quopri              whichdb
_weakrefset         gio                 random              wsgiref
abc                 glib                re                  wx
aifc                glob                readline            wxversion
antigravity         gobject             repr                xdg
anydbm              google              resource            xdrlib
appdirs             grp                 retrying            xml
argparse            gtk                 rexec               xmllib
array               gtkunixprint        rfc822              xmlrpclib
asn1crypto          gyp                 rlcompleter         xxsubtype
ast                 gzip                robotparser         zipfile
asynchat            hashlib             rpm                 zipimport
asyncore            heapq               runpy               zlib
atexit              hmac                sched               
atk                 hotshot             secretstorage       
audiodev            html5lib            select          

///////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

How can i deal with this problem or give me some relevant information
Thank you

How did you install kicad? This seems like nightly snapshot of 5.1 branch.
You need python3, not python.

5.1.5
Installed in a week

Run this in terminal, it should print a 0:

python3 << EOF
import pcbnew
print(pcbnew.F_Cu)
EOF

in Terminal this print this

XXXXX@XX-U:~$ python3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pcbnew
>>> print(pcbnew.F_Cu)
0
>>> 

Can I forcibly switch to python3 by changing the configuration file?

That means issue is not with python or with lack of pcbnew bindings. Must be something in kicad package itself. I don’t use ubuntu so can’t help much further but try this as well.
Launch pcbnew from terminal and then try to open console. Any error messages in terminal can hint at the root cause.

Switch what to python3? KiCad uses python3 already (at least on linux).

To assist the troubleshooting, on KiCad’s about window there is a button titled “Copy Version Info”. Please use that button and clipboard paste here. This will also include the build info.

Application: KiCad
Version: 5.1.5-52549c5~84~ubuntu18.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.65.3 OpenSSL/1.1.1c zlib/1.2.11 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.9.0/openssl/zlib nghttp2/1.39.2 librtmp/2.3
Platform: Linux 5.0.0-23-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.65.1
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.58.0
    Compiler: GCC 7.4.0 with C++ ABI 1011

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

I try to launch kicad through Terminal and run the scripting console
Gives me such an error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/kicad/scripting/kicad_pyshell/__init__.py", line 17, in <module>
    import wx
  File "/usr/lib/python3/dist-packages/wx/__init__.py", line 12, in <module>
    __version__ = wx.__version__.VERSION_STRING
AttributeError: module 'wx' has no attribute '__version__'

kicad need wx version is 3.0.4

so,I test run python on terminal ,The version looks right

XXXXX@X-U:~$ python
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> print(wx.version())
4.0.6 gtk3 (phoenix) wxWidgets 3.0.4

It’s strange that you can import wx manually from python3 cli but kicad can’t do it.
Probably site-packages is messed up or some python related environment variable.

Can you do apt show kicad and apt show python3-wxgtk4.0

XXXXX@X-U:~$ apt show kicad
Package: kicad
Version: 5.1.5-201911190827+52549c5~84~ubuntu18.04.1
Priority: optional
Section: electronics
Maintainer: Adam Wolf <adamwolf@feelslikeburning.com>
Installed-Size: 99.1 MB
Depends: libc6 (>= 2.27), libcairo2 (>= 1.14.0), libcurl4 (>= 7.16.2), libgcc1 (>= 1:3.4), libgl1, libglew2.0 (>= 1.12.0), libglu1-mesa | libglu1, liboce-foundation11, liboce-modeling11, liboce-ocaf-lite11, liboce-ocaf11, libpixman-1-0 (>= 0.15.14), libpython3.6 (>= 3.6.5), libstdc++6 (>= 7), libwxbase3.0-0v5 (>= 3.0.4+dfsg), libwxgtk3.0-gtk3-0v5 (>= 3.0.4+dfsg), python3-wxgtk4.0, libngspice-kicad | libngspice0, xsltproc
Recommends: kicad-libraries, kicad-doc-en, kicad-demos
Suggests: extra-xdg-menus, kicad-locale-ko | kicad-locale-ru | kicad-locale-pl | kicad-locale-pt | kicad-locale-ja | kicad-locale-id | kicad-locale-ca | kicad-locale-it | kicad-locale-el | kicad-locale-zh | kicad-locale-de | kicad-locale-sl | kicad-locale-cs | kicad-locale-bg | kicad-locale-sv | kicad-locale-lt | kicad-locale-fi | kicad-locale-fr | kicad-locale-hu | kicad-locale-nl | kicad-locale-es | kicad-locale-sk
Conflicts: kicad-common
Replaces: kicad-common
Download-Size: 22.7 MB
APT-Manual-Installed: yes
APT-Sources: http://ppa.launchpad.net/js-reynaud/kicad-5.1/ubuntu bionic/main amd64 Packages
Description: Electronic schematic and PCB design software
 Kicad is a suite of programs for the creation of printed circuit boards.
 It includes a schematic editor, a PCB layout tool, support tools and a
 3D viewer to display a finished & fully populated PCB.
 .
 Kicad is made up of 5 main components:
 .
 * kicad - project manager
 * eeschema - schematic editor
 * pcbnew - PCB editor
 * gerbview - GERBER viewer
 * cvpcb - footprint selector for components
 .
 Libraries:
 * Both eeschema and pcbnew have library managers and editors for their
 components and footprints
 * You can easily create, edit, delete and exchange library items
 * Documentation files can be associated with components, footprints and key
 words, allowing a fast search by function
 * Very large libraries are available for schematic components and footprints
 * Most components have corresponding 3D models

N: There are 2 additional records. Please use the '-a' switch to see them.
XXXXX@X-U:~$ apt show python3-wxgtk4.0
Package: python3-wxgtk4.0
Version: 4.0.6+dfsg-2
Priority: optional
Section: universe/python
Source: wxpython4.0
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: wxWidgets Maintainers <team+wx@tracker.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 41.0 MB
Provides: python3.7-wxgtk4.0
Depends: python3-pil, python3-six, python3 (<< 3.8), python3 (>= 3.7~), python3-numpy, python3:any, libc6 (>= 2.14), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), libwxbase3.0-0v5 (>= 3.0.4+dfsg), libwxgtk3.0-gtk3-0v5 (>= 3.0.4+dfsg), sip-py3api-12.6
Suggests: wx3.0-doc
Homepage: https://www.wxpython.org/
Download-Size: 6,603 kB
APT-Manual-Installed: no
APT-Sources: http://cz.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
Description: Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit
 wxWidgets (formerly known as wxWindows) is a class library for C++ providing
 GUI components and other facilities on several popular platforms (and some
 unpopular ones as well).
 .
 This package provides a Python 3 interface to the wxGTK library and the
 wxPython runtime support libraries.  This is the Phoenix reimplementation of
 wxPython.

N: There is 1 additional record. Please use the '-a' switch to see it

note: Sorry, add

Well why would you install KiCad from bionic (18.04) if you have eoan (19.10).
Try changing your ppa repo to point to eoan and reinstall kicad.

1 Like

image

1 Like

Thanks everyone for your help

I fixed it

This has nothing to do with the system version, presumably there is a problem with the installation or other operations have damaged the python environment

I reinstalled the ubuntu system and installed kicad in the same way, this time without any problems,

But this is the dumbest and most tiring method.

:sweat_smile:

1 Like

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