Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PythonQt cannot Build



  • Hi All,

    I am new to the forums and I was wondering if someone could help me out with the issues I am having.
    I am trying to use the package, PythonQt here: https://mevislab.github.io/pythonqt/index.html
    to embedded a python script into a C++ Qt front end.
    I am having trouble building any of the examples sketches. I am running ubuntu 16.04 on vmware and I have QT 5 install and I am trying to use python2.7

    I have tried two ways to compile:
    cmd line, I run qmake && make
    I run into an error that says:

    g++ -c -m64 -pipe -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../src -I../../extensions/PythonQt_QtAll -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o main.o main.cpp
    In file included from ../../src/PythonQt.h:46:0,
                     from main.cpp:42:
    ../../src/PythonQtUtils.h:48:22: fatal error: QByteArray: No such file or directory
    compilation terminated.
    Makefile:333: recipe for target 'main.o' failed
    make: *** [main.o] Error 1
    
    

    I also tried building through QtCreator, however the program lists these issues:

    g++ -Wl,-rpath,/home/plloppii/Qt/5.13.0/gcc_64/lib -o ../../lib/PyLauncher_d main.o   -L/usr/lib/python2.7/config-x86_64-linux-gnu -L/usr/lib -lpython2.7 -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L../../lib/../lib -lPythonQt-Qt5-Python2.7_d -lPythonQt_QtAll-Qt5-Python2.7_d /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Widgets.so /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Gui.so /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Core.so -lGL -lpthread   
    /usr/bin/ld: cannot find -lPythonQt-Qt5-Python2.7_d
    /usr/bin/ld: cannot find -lPythonQt_QtAll-Qt5-Python2.7_d
    /usr/bin/ld: cannot find -lGL
    Makefile:266: recipe for target '../../lib/PyLauncher_d' failed
    collect2: error: ld returned 1 exit status
    make: *** [../../lib/PyLauncher_d] Error 1
    07:34:32: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project PyLauncher (kit: Desktop Qt 5.13.0 GCC 64bit)
    When executing step "Make"
    07:34:32: Elapsed time: 00:00.
    

    If anyone could point me in the right direction, it would be greatly appriciated!!

    Regards,
    Noah



  • I use pyqt5 quite frequently for pure python apps with qt guis, but there is something about embedding python code in a qt c++ app that bothers my sensibilities. I think the more professional approach would be to port the python script to c++ or to run it as a separate child process under the control of a qt app. Anyway, just my opionion, but good luck.

    To your specific question though, you are probably missing dev packages required for building the pythonqt package. not sure what those dev packages are but that's my guess. read the pythonqt build/install docs carefully.



  • @Kent-Dorfman
    I think that I could port the python script to c++ or I could just write my GUI in python as well with PyQt or Pyside.

    However my OCD is killing me because this error is just puzzling me.
    In one of the .prf files, there are these lines that don't make sense to me:

    unix::LIBS += -L$$DESTDIR/../lib -lPythonQt_QtAll-Qt5-Python$${PYTHON_VERSION}$${DEBUG_EXT}
    

    What is this looking for? The PythonQt library or the location of the python library itself?


  • Lifetime Qt Champion

    Hi,

    You are at least missing the OpenGL development package.

    As for the others, they are likely generated during the build.



  • @SGaist

    So I tried running a different example script, and I am getting this:

    /home/plloppii/Qt/5.13.0/gcc_64/bin/qmake -o Makefile ../PyLauncher/PyLauncher.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
    g++ -Wl,-rpath,/home/plloppii/Qt/5.13.0/gcc_64/lib -o ../../lib/PyLauncher_d main.o   -L/usr/lib/python2.7/config-x86_64-linux-gnu -L/usr/lib -lpython2.7 -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L../../lib/../lib -lPythonQt-Qt5-Python2.7_d -lPythonQt_QtAll-Qt5-Python2.7_d /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Widgets.so /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Gui.so /home/plloppii/Qt/5.13.0/gcc_64/lib/libQt5Core.so -lGL -lpthread   
    /usr/bin/ld: cannot find -lPythonQt-Qt5-Python2.7_d
    /usr/bin/ld: cannot find -lPythonQt_QtAll-Qt5-Python2.7_d
    collect2: error: ld returned 1 exit status
    Makefile:267: recipe for target '../../lib/PyLauncher_d' failed
    make: *** [../../lib/PyLauncher_d] Error 1
    14:36:53: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project PyLauncher (kit: Desktop Qt 5.13.0 GCC 64bit)
    When executing step "Make"
    14:36:53: Elapsed time: 00:01.
    

    I cant seem to get through this error... It isnt asking me for the GL library anymore, but PythonQt-Qtall files.


Log in to reply