SUMMARY I receive the following error starting krita, with the consequence that the Scripting environment is not functional: ``` Set PYTHONPATH environment variable /usr/lib/krita-python-libs/krita added to PYTHONPATH krita.scripting: "Traceback (most recent call last):" krita.scripting: " File \"/usr/lib/krita-python-libs/krita/__init__.py\", line 32, in <module>" krita.scripting: " import excepthook" krita.scripting: " File \"/usr/lib/krita-python-libs/krita/excepthook.py\", line 14, in <module>" krita.scripting: " import cgitb" krita.scripting: "ModuleNotFoundError: No module named 'cgitb'" krita.scripting: "Could not import krita" ``` I believe this is the consequence of my system Python version being 3.13 and that `cgitb` was removed in 3.13 after being deprecated in 3.11. This may be the result of me using arch and I sincerely hope this is not just an arch user annoyance, I assume this will probably bite scripting users as soon as they reach 3.13. The offending import in `excepthook.py` appears in all branches I've scrounged through on gitlab. STEPS TO REPRODUCE 1. start krita from the commandline OBSERVED RESULT The error message above and an empty tools menu. EXPECTED RESULT A working Scripter SOFTWARE/OS VERSIONS ``` $ python --version Python 3.13.1 $ krita --version krita 5.2.6 $ qtdiag6 Qt 6.8.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240910) on "wayland" OS: Arch Linux [linux version 6.12.6-arch1-1] (...) ``` Thank you!
It would be nice if the python documentation said what replaces this...
(In reply to Halla Rempt from comment #1) > It would be nice if the python documentation said what replaces this... My understanding is that cgitb is unnecessary, it just replaces the standard exception handle for one that provides more detailed error reports. It's no longer included in the standard library but can be imported via an external library which is a drop in replacement (https://pypi.org/project/legacy-cgi/) The documentation does mention this, I just didn't bother linking to it because I am a moron (https://docs.python.org/3.13/library/cgitb.html#module-cgitb)...
*** Bug 497937 has been marked as a duplicate of this bug. ***
Just install https://archlinux.org/packages/extra/any/python-legacy-cgi/
Created attachment 176906 [details] attachment-1376618-0.html Yes, I could do that. But this is no fix, but a workaround. This should be considered in code. ________________________________ From: Antonio Rojas <bugzilla_noreply@kde.org> Sent: Friday, December 27, 2024 12:10:16 PM To: Christian Petersen <me@nordinary.com> Subject: [krita] [Bug 497859] cgitb is required for python scripting but was removed from Python 3.13. https://bugs.kde.org/show_bug.cgi?id=497859 --- Comment #4 from Antonio Rojas <arojas@archlinux.org> --- Just install https://archlinux.org/packages/extra/any/python-legacy-cgi/ -- You are receiving this mail because: You are on the CC list for the bug.
(In reply to Antonio Rojas from comment #4) > Just install https://archlinux.org/packages/extra/any/python-legacy-cgi/ That is a hacky workaround (which I can confirm works), but I agree with me@nordinary.com that this isn't a proper solution to the root of the problem. For one it would require every user of krita to modify their system python. Secondly, it would continue to use a deprecated library. Instead it would also be possible to use `traceback` from the stdlib which essentially contains the same functionality.
(In reply to a2800276 from comment #6) > (In reply to Antonio Rojas from comment #4) > > Just install https://archlinux.org/packages/extra/any/python-legacy-cgi/ > > That is a hacky workaround (which I can confirm works), but I agree with > me@nordinary.com that this isn't a proper solution to the root of the > problem. No, it's not a "hacky workaround". It's the actual solution of the issue for Arch Linux users: install the required dependencies. That doesn't mean the code should not eventually be ported upstream.
> No, it's not a "hacky workaround". It's the actual solution of the issue for > Arch Linux users: install the required dependencies. That doesn't mean the > code should not eventually be ported upstream. Is there anything I can do to facilitate a more sustainable solution? Not sure when we can expect more mainstream distros and operating systems to update to the current Python release, but they will be affected sooner or later. I'm glad we at least agree this needs a proper fix eventually :/
I think using traceback would be the best solution. I won't be doing that right now, but I intend to figure that out and do it before we build 5.2.9.
Git commit 2fef5bcd54b435aaf91da7b9ef428995143f8f03 by Halla Rempt. Committed on 06/01/2025 at 10:36. Pushed by rempt into branch 'master'. Use traceback instead of cgitb It's not as pretty, but it's standard. M +3 -3 plugins/extensions/pykrita/plugin/krita/excepthook.py https://invent.kde.org/graphics/krita/-/commit/2fef5bcd54b435aaf91da7b9ef428995143f8f03
Git commit 94584ad995494d332c3716b79e2ba060715925f5 by Halla Rempt. Committed on 06/01/2025 at 10:36. Pushed by rempt into branch 'krita/5.2'. Use traceback instead of cgitb It's not as pretty, but it's standard. (cherry picked from commit 2fef5bcd54b435aaf91da7b9ef428995143f8f03) M +3 -3 plugins/extensions/pykrita/plugin/krita/excepthook.py https://invent.kde.org/graphics/krita/-/commit/94584ad995494d332c3716b79e2ba060715925f5
Nah, I messed up. I tested the wrong build.
Git commit 19be76b07b2f8c6d1bd69ffdd9d006bb6834676b by Halla Rempt. Committed on 06/01/2025 at 11:41. Pushed by rempt into branch 'master'. Properly create the backtrace string M +2 -2 plugins/extensions/pykrita/plugin/krita/excepthook.py https://invent.kde.org/graphics/krita/-/commit/19be76b07b2f8c6d1bd69ffdd9d006bb6834676b
Git commit 38ad4fd19ca7f9413cfe2b54d975c0fff937ce2a by Halla Rempt. Committed on 06/01/2025 at 11:42. Pushed by rempt into branch 'krita/5.2'. Properly create the backtrace string (cherry picked from commit 19be76b07b2f8c6d1bd69ffdd9d006bb6834676b) M +2 -2 plugins/extensions/pykrita/plugin/krita/excepthook.py https://invent.kde.org/graphics/krita/-/commit/38ad4fd19ca7f9413cfe2b54d975c0fff937ce2a