I am currently developing a simple Qt application with Python for myself to learn foreign languages. When I wanted to add support for Japanese, I recognized that while I have no problems with Anki and other Qt applications, Japanese input did not work in my own application.

I normally use fcitx5, but then switched to fcitx, because I first suspected Qt6 being the problem and there’s a dedicated package fcitx-qt6. It still did not work. Next, I tried several different libraries thinking that maybe it’s a problem with the Python library. PySide6 (Qt6), PySide2 (Qt5) and PyQt5 (Qt5), none of them worked.

When you know the solution, it’s really simple though: The Python libraries (at least when installed from PyPI) do not ship with the required plugin for fcitx. On my system Qt, there is the file /usr/lib/qt6/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin-qt6.so, but listing the virtualenv folder gives:

$ ls -l venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforminputcontexts/
total 208
-rwxr-xr-x 1 brati users  27712 Mar 19 11:42 libcomposeplatforminputcontextplugin.so
-rwxr-xr-x 1 brati users 162240 Mar 19 11:42 libibusplatforminputcontextplugin.so
-rwxr-xr-x 1 brati users  19080 Mar 19 11:42 libqtvirtualkeyboardplugin.so

Copying the file from the system Qt6 into the virtualenv Qt6 solved the issue!

cp /usr/lib/qt6/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin-qt6.so \
    venv/lib/python3.10/site-packages/PySide6/Qt/plugins/platforminputcontexts/
I do not maintain a comments section. If you have any questions or comments regarding my posts, please do not hesitate to send me an e-mail to blog@stefan-koch.name.