KiCad 8 on Ubuntu: ModuleNotFoundError: No module named 'pcbnew'

Hi Everyone,

I’m running Ubuntu 22.04.4, and I’ve installed Kicad 8 with:

sudo apt install --install-recommends kicad

Everything seems to be working great except when I try to open the python scripting console in PCBNew, I get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/kicad/scripting/kicad_pyshell/__init__.py", line 23, in <module>
    import pcbnew
ModuleNotFoundError: No module named 'pcbnew'

I’m not sure where pcbnew.py is supposed to live, but I don’t see it anywhere under /usr/share/kicad.

Does anyone have any suggestions for how I may try to fix this error, or if there’s more debug information I can provide?

Thanks!
Gabe

Fixed in the next version. 8.0.1 will be out soon, and 8.0.1-rc1 is out now (I’m not sure how to install an RC on Ubuntu).

Wow, thanks for the super quick reply! I appreciate it. Looking forward to 8.0.1 then!

Installing Ubuntu using the three lines below will replace 8.0.0 with 8.0.1-rc1. When 8.0.1 is available, installing 8.0.1 will replace 8.0.1-rc1 :slightly_smiling_face:

2 Likes

Current package for Ubuntu 20.04 (KiCad 8.0.1) has the same problem.

The file is there, but in the wrong place. The package contains /usr/lib/python3.8/site-packages/pcbnew.py which isn’t in Python sys.path.

The file should be in /usr/lib/python3.8/pcbnew.py or perhaps /usr/local/lib/python3.8/dist-packages/pcbnew.py.

I think @Seth_h should take a look at the official Debian packages for details about the best practices.

For a full discussion about this issue you can visit: KiBot issue 606

P.S. If you look at the package for 22.04 you’ll see pcbnew is at: /usr/lib/python3/dist-packages

I am unfamiliar with this document. But since you seem to know about the contents, I would recommend you submit a merge request with the appropriate changes.

O no, more breakage? This is the curse of morons maintaining python pushing sysconfig as a replacement for distutils (now removed in python 3.12) while splintering the api.

You will want to look here and figure at what additional else if case is needed, without breaking all the other platforms, lolololololol.

We already attempted to fix it once for Debian which is already in 8.0.1

Unless its a issue specific in python 3.8? Hah

Hi @Seth_h !

I’m not expert in Debian packages, this is why I suggest borrowing more from the official Debian packages.

A couple of times I created Debian files to package KiCad, I always used the files derived from the Debian packages.

In this case I found the issue because a KiBot user failed to install it on Ubuntu 20.04 (on WSL). After asking the user to do a lot of tests I found that KiCad package is using a directory that isn’t in Python’s sys.path. And looking at other Ubuntu and Debian packages for KiCad isn’t the same.

I generate Python packages for KiBot (and other plugins), but I use debmake using the pybuild system. So I don’t mess much with the Python part, just let debmake do the job.

This change/breakage occurred to our cmake script needing to evolve for python 3.12 which removed distutils. cmake is now using sysconfig which thanks to Linux distros and the inepitude of python, sysconfig has branching implementations for finding the right path depending on your linux distro and os (yes linux distro itself is an additional variance). distutils had one very clear function and always returned the right path.

The Debian packages wouldn’t help here. It needs to be fixed in the cmake. Especially since the most recent Debian stable is still on 6.0 and backports on 7.0, lol.

This change is from 8.0+

There is a 8.0 in Debian experimental but there are no patches to fix the cmake install
https://sources.debian.org/patches/kicad/8.0.1+dfsg-1/

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