我用这样的python 2.7创建了一个虚拟环境:virtualenv py_env

然后我想安装SIP(sip-4.19.1)和PyQt5(PyQt-gpl-5.5.1),所以我下载了两个(riverbankcomputing)并试图像这样安装它们:

cd py_env
cd sip-4.19.1/
python configure --incdir=../include/python2.7/
make
sudo make install

这很好用,python确认现在可以导入sip:

>>> import sip
>>> sip
<module 'sip' from 
'/home/robin/Develop/py_todo_env/local/lib/python2.7/site-
packages/sip.so'>

接下来,我这样做是为了安装PyQt5:

cd ../PyQt-gpl-5.5.1/
python configure --sip-incdir=../include/sip/
make
ERROR!!!

运行时出现错误:

g++ -c -m64 -pipe -fno-exceptions -O2 -Wall -W -D_REENTRANT -fPIC -
DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -I. -I. -isystem /usr/include/python2.7 -I../qpy/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o qpycore_types.o ../qpy/QtCore/qpycore_types.cpp
../qpy/QtCore/qpycore_types.cpp: In function ‘int pyqtWrapperType_init(pyqtWrapperType*, PyObject*, PyObject*)’:
../qpy/QtCore/qpycore_types.cpp:160:5: error: ‘pyqt5ClassTypeDef’ was not declared in this scope
     pyqt5ClassTypeDef *pyqt_td = (pyqt5ClassTypeDef *)((sipWrapperType *)self)->type;
     ^
../qpy/QtCore/qpycore_types.cpp:160:24: error: ‘pyqt_td’ was not declared in this scope
     pyqt5ClassTypeDef *pyqt_td = (pyqt5ClassTypeDef *)((sipWrapperType *)self)->type;
                        ^
../qpy/QtCore/qpycore_types.cpp:160:54: error: expected primary-expression before ‘)’ token
     pyqt5ClassTypeDef *pyqt_td = (pyqt5ClassTypeDef *)((sipWrapperType *)self)->type;
                                                      ^
../qpy/QtCore/qpycore_types.cpp: In function ‘const QMetaObject* get_qmetaobject(pyqtWrapperType*)’:
../qpy/QtCore/qpycore_types.cpp:583:52: error: ‘pyqt5ClassTypeDef’ was not declared in this scope
     return reinterpret_cast<const QMetaObject *>(((pyqt5ClassTypeDef *)((sipWrapperType *)pyqt_wt)->type)->static_metaobject);
                                                    ^
../qpy/QtCore/qpycore_types.cpp:583:71: error: expected primary-expression before ‘)’ token
     return reinterpret_cast<const QMetaObject *>(((pyqt5ClassTypeDef *)((sipWrapperType *)pyqt_wt)->type)->static_metaobject);
                                                                       ^
Makefile:1892: recipe for target 'qpycore_types.o' failed
make[1]: *** [qpycore_types.o] Error 1
make[1]: Leaving directory '/home/robin/Develop/py_todo_env/PyQt-gpl-5.5.1/QtCore'
Makefile:56: recipe for target 'sub-QtCore-make_first-ordered' failed
make: *** [sub-QtCore-make_first-ordered] Error 2

我尝试过不同版本的sip和pyqt5,有些工作,例如pyqt 5.10,但是我没有QtWebEngineWidgets模块可以导入,所以那里也有问题..为什么这么难做到这一点?