Bug 518163 - Python-PyQt conflict avoidance completely breaks plugin loading
Summary: Python-PyQt conflict avoidance completely breaks plugin loading
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (other bugs)
Version First Reported In: 6.0.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
: 518195 518233 518249 (view as bug list)
Depends on:
Blocks:
 
Reported: 2026-03-26 12:57 UTC by Raidon Chrome
Modified: 2026-04-01 09:25 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
My really dumb patch to fix this (524 bytes, patch)
2026-03-26 12:57 UTC, Raidon Chrome
Details
new patch based on !2723 (993 bytes, patch)
2026-03-27 07:23 UTC, Raidon Chrome
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raidon Chrome 2026-03-26 12:57:14 UTC
Created attachment 191029 [details]
My really dumb patch to fix this

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
https://invent.kde.org/graphics/krita/-/commit/38bbeb8a1882150379fafde54f25222e5fade146
This commit introduced a way to dynamically load either PyQT5 or PyQT6, but ends up removing /usr/lib/python3.14/site-packages from sys.path, breaking all built-in plugins. 

STEPS TO REPRODUCE
1. Lauch Krita 6.0.0-1 on Arch or CachyOS 
2. Open settings and observe broken plugins

OBSERVED RESULT
No plugins can be loaded

EXPECTED RESULT
Built-in plugins available

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: ArchLinux 
KDE Frameworks Version: 25.12.3-1.1
Qt Version: 6.10.2-1

ADDITIONAL INFORMATION
https://dpaste.com/5LLS6GZZ5
Comment 1 Bug Janitor Service 2026-03-26 17:46:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/2723
Comment 2 Freya Lupen 2026-03-26 17:47:45 UTC
Is this is with a distro build relying on system site-packages where there happen to be two version of PyQt installed?

Krita is looking for PyQt6 but found PyQt5 and tried to remove that. (The error message which says it can't find the Qt5 bindings is misleading.)
Re-adding the system site-packages would re-add PyQt5, which would crash Krita if accessed by outdated user plugins. (Built-in plugins prioritize PyQt6, so they only crash the other way around.)

I have a potential fix in the above merge request which is built on those assumptions.
It re-adds the other modules beside where the conflicting PyQt was found.
So if PyQt5 and PyQt6 were in the same site-packages folder, it would be able to find the right one.
Comment 3 Raidon Chrome 2026-03-26 17:49:49 UTC
(In reply to Freya Lupen from comment #2)
> Is this is with a distro build relying on system site-packages where there
> happen to be two version of PyQt installed?
> 
> Krita is looking for PyQt6 but found PyQt5 and tried to remove that. (The
> error message which says it can't find the Qt5 bindings is misleading.)
> Re-adding the system site-packages would re-add PyQt5, which would crash
> Krita if accessed by outdated user plugins. (Built-in plugins prioritize
> PyQt6, so they only crash the other way around.)
> 
> I have a potential fix in the above merge request which is built on those
> assumptions.
> It re-adds the other modules beside where the conflicting PyQt was found.
> So if PyQt5 and PyQt6 were in the same site-packages folder, it would be
> able to find the right one.

Yes, both python-pyqt6 and python-pyqt5 are installed at the same time, you're correct
Comment 4 dra.w.p.il.e+bugskde 2026-03-27 04:41:48 UTC
*** Bug 518195 has been marked as a duplicate of this bug. ***
Comment 5 Raidon Chrome 2026-03-27 07:22:53 UTC
https://dpaste.com/GDXHL8SX6
I tried using __init__.py from this MR - https://invent.kde.org/graphics/krita/-/merge_requests/2723
It looks like it's not fixing the issue. 
If importlib.util.find_spec("PyQt5") returns None, the os.scandir never runs. So PyQt6 is not going to be imported.
I've made another patch based on that MR that, once again, fixes this on my system. (attaching as new.patch)
Comment 6 Raidon Chrome 2026-03-27 07:23:32 UTC
Created attachment 191055 [details]
new patch based on !2723
Comment 7 dra.w.p.il.e+bugskde 2026-03-27 16:52:17 UTC
*** Bug 518233 has been marked as a duplicate of this bug. ***
Comment 8 Freya Lupen 2026-03-27 20:40:36 UTC
I've updated the MR to remove the sys.path modifications, could you test if it works now?
Comment 9 Raidon Chrome 2026-03-27 20:44:00 UTC
(In reply to Freya Lupen from comment #8)
> I've updated the MR to remove the sys.path modifications, could you test if
> it works now?

It does! Thank you.
Comment 10 dra.w.p.il.e+bugskde 2026-03-28 08:17:49 UTC
*** Bug 518249 has been marked as a duplicate of this bug. ***
Comment 11 Dmitry Kazakov 2026-04-01 09:25:22 UTC
Git commit f6d7040613dd49aa47e74f7c55590f3e553125c9 by Dmitry Kazakov, on behalf of Freya Lupen.
Committed on 01/04/2026 at 09:09.
Pushed by dkazakov into branch 'master'.

Disallow importing conflicting version of PyQt

This replaces the sys.path modification with a better hack.
Now we simply override builtins.__import__ to raise
a ModuleNotFoundError if an attempt is made to load the wrong PyQt.

M  +15   -16   plugins/extensions/pykrita/plugin/krita/__init__.py

https://invent.kde.org/graphics/krita/-/commit/f6d7040613dd49aa47e74f7c55590f3e553125c9
Comment 12 Dmitry Kazakov 2026-04-01 09:25:53 UTC
Git commit 731367f8245dcc3889ad6445d6da426432c5bfc8 by Dmitry Kazakov, on behalf of Freya Lupen.
Committed on 01/04/2026 at 09:25.
Pushed by dkazakov into branch 'krita/6.0'.

Disallow importing conflicting version of PyQt

This replaces the sys.path modification with a better hack.
Now we simply override builtins.__import__ to raise
a ModuleNotFoundError if an attempt is made to load the wrong PyQt.

M  +15   -16   plugins/extensions/pykrita/plugin/krita/__init__.py

https://invent.kde.org/graphics/krita/-/commit/731367f8245dcc3889ad6445d6da426432c5bfc8