Error on clean FlatPak install and plugins not working: AttributeError: 'moduledef' object has no attribute 'delete_SwigPyIterator'

When opening the scripting console in pcbnew on a completely clean flatpak install, the below error is emitted. In addition to this, no plugins appear in the menu when installed:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/app/share/kicad/scripting/kicad_pyshell/__init__.py", line 23, in <module>
    import pcbnew
  File "/app/lib/python3.13/site-packages/pcbnew.py", line 68, in <module>
    class SwigPyIterator(object):
    ...<76 lines>...
            return self
  File "/app/lib/python3.13/site-packages/pcbnew.py", line 76, in SwigPyIterator
    __swig_destroy__ = _pcbnew.delete_SwigPyIterator
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'moduledef' object has no attribute 'delete_SwigPyIterator'

KiCad Version

Application: KiCad x86_64 on x86_64

Version: 9.0.6, release build

Libraries:
	wxWidgets 3.2.8
	FreeType 2.14.1
	HarfBuzz 11.4.5
	FontConfig 2.17.1

Platform: Freedesktop SDK 25.08 (Flatpak runtime), 64 bit, Little endian, wxGTK, X11, KDE, wayland
OpenGL: NVIDIA Corporation, NVIDIA GeForce RTX 4070 SUPER/PCIe/SSE2, 4.6.0 NVIDIA 580.95.05

	wxWidgets: 3.2.8 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.89.0
	OCC: 7.9.2
	Curl: 8.15.0
	ngspice: 45.2
	Compiler: GCC 15.2.0 with C++ ABI 1020
	KICAD_IPC_API=ON

Locale: 
	Lang: en_US
	Enc: UTF-8
	Num: 1,234.5
	Encoded кΩ丈: D0BACEA9E4B888 (sys), D0BACEA9E4B888 (utf8)