-
fcitx5 cannot be triggered within a Python venv (because PySide6, the Qt Python bindings, deploys its own build of the libraries, I assume). To reproduce, here is a simple editable Qt text widget: import sys
from PySide6.QtWidgets import QApplication, QTextEdit
app = QApplication(sys.argv)
widget = QTextEdit("Edit me")
widget.show()
app.exec() Executing this Python script on a system where fcitx5 is running works just fine. On the other hand, if run within a virtual env, I'm unable to trigger fcitx: python -m venv venv
. venv/bin/activate
pip install pyside6
python test.py What are the solutions or workarounds available at this point? Would it be possible to have a fcitx pip module we could install within the venv to make the communication outside or something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Try set QT_IM_MODULE=ibus before launch your pyqt application. I believe in the virtual env you're not using system qt, thus you will not have fcitx5-qt installed. Note this may not work well under wayland. If you're using KDE wayland, you can follow this https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland#KDE_Plasma instead to make qt use its wayland input method protocol to talk to fcitx. |
Beta Was this translation helpful? Give feedback.
-
That works (I had to install ibus though obviously), thank you. How come this seems to still connect to fcitx5, what's the relationship here?
So I'm assuming that works because in the venv there is
Thanks, I'm using i3 (X11) though. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the workaround, your answers have been very helpful. I'm assuming similar issues would be raised with GTK, and I don't know if there is a possibility that such scenario could work out of the box at some point, but for now I'm closing the discussion as resolved since it solves my issue. Thanks. |
Beta Was this translation helpful? Give feedback.
Try set QT_IM_MODULE=ibus before launch your pyqt application. I believe in the virtual env you're not using system qt, thus you will not have fcitx5-qt installed. Note this may not work well under wayland.
If you're using KDE wayland, you can follow this https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland#KDE_Plasma instead to make qt use its wayland input method protocol to talk to fcitx.