Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Could not import pygs #8

Closed
skrech opened this issue Nov 25, 2014 · 10 comments
Closed

Could not import pygs #8

skrech opened this issue Nov 25, 2014 · 10 comments

Comments

@skrech
Copy link

skrech commented Nov 25, 2014

Hi,

I'm having problem importing pygs. With python3 and PyQt5 when I import pygs, I'm getting:

import pygs
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/local/lib/python3.4/dist-packages/pygs.so: undefined symbol: _ZTI26QAbstractNativeEventFilter

Installed pygs using pip3:
sudo pip3 install PyGlobalShortcut

I'm on Ubuntu 14.10 x64.

@Asvel
Copy link
Owner

Asvel commented Nov 25, 2014

Is your PyQt5 working fine?

@skrech
Copy link
Author

skrech commented Nov 25, 2014

Yes, I'm trying to make global shortcuts for my PyQt5 application.

@skrech
Copy link
Author

skrech commented Nov 25, 2014

I've installed PyGlobalShortcut on python2 too, and the same error occurs.

@ColinDuquesnoy
Copy link

Maybe the extension linked to the wrong qt library?

@skrech Could you paste the pip output?

@Asvel maybe we should change the build process so that it generates extension for both PyQt5 and PyQt4 (e.g. pygs4 and pygs5). That way it would be possible to have one app that use pygs + pyqt4 and another app that use pygs + pyqt5 on the same system. Currently this is impossible.

@skrech
Copy link
Author

skrech commented Nov 25, 2014

pip3 output:

$ sudo pip3 install PyGlobalShortcut
Downloading/unpacking PyGlobalShortcut
Downloading PyGlobalShortcut-0.2.3.zip (44kB): 44kB downloaded
Running setup.py (path:/tmp/pip_build_root/PyGlobalShortcut/setup.py) egg_info for package PyGlobalShortcut

Installing collected packages: PyGlobalShortcut
Running setup.py install for PyGlobalShortcut
building 'QxtGlobalShortcut' library
Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!
g++ -c -m64 -pipe -O2 -fPIC -D_REENTRANT -Wall -W -DBUILD_QXT_CORE -DBUILD_QXT_GUI -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I../../lib -I../../libqxt/src/core -I../../libqxt/src/widgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0/QtGui -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. -o qxtglobal.o ../../libqxt/src/core/qxtglobal.cpp
g++ -c -m64 -pipe -O2 -fPIC -D_REENTRANT -Wall -W -DBUILD_QXT_CORE -DBUILD_QXT_GUI -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I../../lib -I../../libqxt/src/core -I../../libqxt/src/widgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0/QtGui -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. -o qxtglobalshortcut.o ../../libqxt/src/widgets/qxtglobalshortcut.cpp
g++ -c -m64 -pipe -O2 -fPIC -D_REENTRANT -Wall -W -DBUILD_QXT_CORE -DBUILD_QXT_GUI -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I../../lib -I../../libqxt/src/core -I../../libqxt/src/widgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0/QtGui -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. -o qxtglobalshortcut_x11.o ../../libqxt/src/widgets/x11/qxtglobalshortcut_x11.cpp
/usr/lib/x86_64-linux-gnu/qt5/bin/moc -DBUILD_QXT_CORE -DBUILD_QXT_GUI -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/tmp/pip_build_root/PyGlobalShortcut/lib -I/tmp/pip_build_root/PyGlobalShortcut/libqxt/src/core -I/tmp/pip_build_root/PyGlobalShortcut/libqxt/src/widgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0 -I/usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0/QtGui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/4.9 -I/usr/include/x86_64-linux-gnu/c++/4.9 -I/usr/include/c++/4.9/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.9/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../../libqxt/src/widgets/qxtglobalshortcut.h -o moc_qxtglobalshortcut.cpp
g++ -c -m64 -pipe -O2 -fPIC -D_REENTRANT -Wall -W -DBUILD_QXT_CORE -DBUILD_QXT_GUI -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I../../lib -I../../libqxt/src/core -I../../libqxt/src/widgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.0/QtGui -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. -o moc_qxtglobalshortcut.o moc_qxtglobalshortcut.cpp
rm -f libQxtGlobalShortcut.a
ar cqs libQxtGlobalShortcut.a qxtglobal.o qxtglobalshortcut.o qxtglobalshortcut_x11.o moc_qxtglobalshortcut.o
building 'pygs' extension
g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -O2 -Wall -W -D_REENTRANT -DNDEBUG -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -I. -I/tmp/pip_build_root/PyGlobalShortcut/pygs/../libqxt/src/core -I/tmp/pip_build_root/PyGlobalShortcut/pygs/../libqxt/src/widgets -I/usr/include/python3.4m -I/usr/share/qt4/mkspecs/default -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/X11R6/include -o sippygscmodule.o sippygscmodule.cpp
g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -O2 -Wall -W -D_REENTRANT -DNDEBUG -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -I. -I/tmp/pip_build_root/PyGlobalShortcut/pygs/../libqxt/src/core -I/tmp/pip_build_root/PyGlobalShortcut/pygs/../libqxt/src/widgets -I/usr/include/python3.4m -I/usr/share/qt4/mkspecs/default -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/X11R6/include -o sippygsQxtGlobalShortcut.o sippygsQxtGlobalShortcut.cpp
g++ -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-O1 -shared -Wl,-O1 -Wl,--version-script=pygs.exp -o pygs.so sippygscmodule.o sippygsQxtGlobalShortcut.o -L/tmp/pip_build_root/PyGlobalShortcut/build/temp.linux-x86_64-3.4 -L/usr/lib -L/usr/X11R6/lib -lQxtGlobalShortcut -lQtCore -lQtGui

Successfully installed PyGlobalShortcut
Cleaning up...

@ColinDuquesnoy
Copy link

Thanks. The issue is that the pyqt extension links with Qt4 while the qxtGlobalShortcut (c++) links with Qt5. To properly build pygs on systems that have both PyQt4 and PyQt5, you must set the QT_SELECT environment variable accordingly (as specified in the readme).

Could you try the following:

$ export QT_SELECT=5
$ sudo pip3 install PyGlobalShortcut

@Asvel
Copy link
Owner

Asvel commented Nov 26, 2014

Add a check point to detect this situation.

@ColinDuquesnoy
I don't think add a version suffix like PyQt is a good idea (actually the version suffix of PyQt has troubled me many times), if someone need coexist various version of same lib, something like virtualenv could be used.

@Asvel Asvel closed this as completed Nov 26, 2014
@ColinDuquesnoy
Copy link

Hmm I think virtualenv are ok for developpers but for not for end user. It maybe a real pain to install PyQt in a virtualenv (copying the PyQt5 folder from sites-packages does not always work). End user are not always python developers and don't care about python specific solution. What about application distributed by a linux distribution? They won't install in a virtualenv...

Also if linux distributions provides support for both PyQt4 and PyQt5 I think we should do the same.

@Asvel
Copy link
Owner

Asvel commented Nov 26, 2014

You are right, let's figure out how to support coexisting.

@ColinDuquesnoy
Copy link

I would add a suffix. pygs4 would mean that it is built to work with PyQt4 (which can be linked to Qt4 or Qt5) and pygs5 would mean that it is built to work with PyQt5. Nothing prevents you from writing a pygs wrapper module that conditionally import the proper module and expose a unified API. If you do that, don't forget to give the user a way to choose the desired API (e.g. using an environment variable).

You probably just have to rework your build functions a bit in setup.py. Try each API, skip the one that are not available and built each candidate separately. The good thing is that you already link statically with libQxt so there is no need to add a suffix to libQxt ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants