0

I'm compiling my pyqt project into an executable with pyinstaller, I'm using Qt virtual keyboard in the code and it works when running with python but after compiling with pyinstaller the executable doesn't have the keyboard.

Example code:

from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5 import uic

os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

class Gui(QWidget):
    def __init__(self):
        super(Gui, self).__init__()

        uic.loadUi('test.ui', self)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    gui = Gui()
    gui.show()
    sys.exit(app.exec())

The command I'm using to compile:

pyinstaller --clean --onefile --add-data "./test.ui:." --noconsole vkeyboard_test.py

I used the answer in this post to install qtvirtualkeyboard on linux, what should I add to the pyinstaller command to include the virtual keyboard?

Edit: I'm using archlinux and I found that there is a package called qt5-virtualkeyboard, could it help with this problem in any way possible?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • first run compiled version in console to see error messages. – furas Nov 03 '21 at 17:20
  • No errors show up in the console, the module doesn't get included in the compiled binary. – Arsany Samuel Nov 04 '21 at 08:29
  • normally when you run .exe file in console then it shows error message and it helps to see what is the real problem. Without error you have to read documentation to see how to add manually modules/libraries/resorces – furas Nov 04 '21 at 13:43
  • I've read the documentation of pyinstaller and tried the options mentioned [here](https://pyinstaller.readthedocs.io/en/stable/usage.html#what-to-bundle-where-to-search) but with no luck. The problem is that qvirtualkeyboard is not a builtin module in pyqt5, it should be installed manually by copying files as I mentioned in the post in order to use it so including the modules with pyinstaller --collect options doesn't work. Honestly, I don't fully understand the other options in this section of the documentation, any help? – Arsany Samuel Nov 06 '21 at 07:26
  • 1
    I was thinking about page [Using Spec Files](https://pyinstaller.readthedocs.io/en/stable/spec-files.html) and adding manually `/full/path/to/some/files` to file `.spec` (probably to `binaries=[...]`) – furas Nov 06 '21 at 09:13
  • Thanks @furas that's really helpful. I did this and [this](https://pastebin.com/Z38Uz7Gm) is the spec file. After compiling I get this error while running the virtual keyboard by selecting a QLineEdit: `qrc:/QtQuick/VirtualKeyboard/content/InputPanel.qml:33:1: module "QtQuick.VirtualKeyboard" is not installed` `import QtQuick.VirtualKeyboard 2.1` I don't know if I should copy files into a similar tree as the module or not, in this spec file I copied all to the same directory. – Arsany Samuel Nov 06 '21 at 10:21
  • 1
    as I know normally it puts it in some subfolder `plugin`. PyQt uses this folder also to put other extensions - so maybe you could find other question which has problem with different extension in Qt and maybe it will show how to load it correctly. – furas Nov 06 '21 at 12:41

0 Answers0