Tôi đang gặp một số sự cố khi xây dựng PyQt5 trên Ubuntu 14.04. Tôi đang làm việc với một số mã có một sự phụ thuộc cứng trên Python 2,7; vì vậy, tôi không thể sử dụng các gói python3 từ kho lưu trữ của Ubuntu. Các tìm kiếm thêm về các gói của Ubuntu cho thấy rằng có các gói dev và doc cho Python 2 pyqt5. Nhưng, không có gì để cài đặt các thư viện cần thiết để viết mã.Sự cố khi xây dựng PyQt5 trên Ubuntu 14.04
Điều này đã dẫn tôi tạo một bản dựng tùy chỉnh cho PyQt5. Tôi nhận được mã nguồn cho phiên bản 5.5 từ đây: https://www.riverbankcomputing.com/software/pyqt/download5 và tôi đang sử dụng ngụm như được cung cấp bởi repos Ubuntu (cài đặt của kubuntu-máy tính để bàn đòi hỏi ngụm).
Tôi đọc mà nó dễ dàng để có các phiên bản không phù hợp của ngụm vì vậy tôi đã làm việc kiểm tra sau:
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sip
>>> print(sip, sip.SIP_VERSION_STR)
(<module 'sip' from '/usr/lib/python2.7/dist-packages/sip.so'>, '4.16.9')
Và:
$ sip -V
4.16.9
Ngoài ra tôi đang sử dụng các công cụ Qt5 cung cấp bởi Repos Ubuntu . Điều này bao gồm việc cài đặt qtdeclarative5- * (có thể là quá mức cần thiết) và qt5-default. Dưới đây là một số thông tin về qmake:
qmake --version
QMake version 3.0
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu
Tôi hiện đã cài đặt PyQt4 và đọc trên quá trình cài đặt lưu ý rằng đây sẽ là tốt miễn là họ được cả biên dịch chống lại cùng một phiên bản của ngụm.
Sau khi tải về, tôi mở gói tarball và cố gắng một xây dựng như sau:
đầu rasudo ln -s /usr/include/python2.7 /usr/local/include/python2.7
python configure.py --sip-incdir=/usr/include/python2.7/
make
Cấu hình xuất hiện để xác định đúng phiên bản của ngụm và tôi nhận được như sau (dường như) ngụm liên quan biên dịch lỗi từ làm :
make[1]: Entering directory `~/Downloads/PyQt-gpl-5.5/QtWebKit'
g++ -c -m64 -pipe -fno-exceptions -O2 -Wall -W -D_REENTRANT -fPIC -DSIP_PROTECTED_IS_PUBLIC -Dprotected=public -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WEBKIT_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/python2.7 -I/usr/include/qt5 -I/usr/include/qt5/QtWebKit -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o sipQtWebKitQWebSecurityOrigin.o sipQtWebKitQWebSecurityOrigin.cpp
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp: In function ‘PyObject* meth_QWebSecurityOrigin_addAccessWhitelistEntry(PyObject*, PyObject*)’:
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:384:9: error: ‘SubdomainSetting’ is not a member of ‘QWebSecurityOrigin’
QWebSecurityOrigin::SubdomainSetting a2;
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:384:46: error: expected ‘;’ before ‘a2’
QWebSecurityOrigin::SubdomainSetting a2;
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:387:214: error: ‘a2’ was not declared in this scope
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J1E", &sipSelf, sipType_QWebSecurityOrigin, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State, sipType_QWebSecurityOrigin_SubdomainSetting, &a2))
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:389:21: error: ‘class QWebSecurityOrigin’ has no member named ‘addAccessWhitelistEntry’
sipCpp->addAccessWhitelistEntry(*a0,*a1,a2);
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp: In function ‘PyObject* meth_QWebSecurityOrigin_removeAccessWhitelistEntry(PyObject*, PyObject*)’:
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:417:9: error: ‘SubdomainSetting’ is not a member of ‘QWebSecurityOrigin’
QWebSecurityOrigin::SubdomainSetting a2;
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:417:46: error: expected ‘;’ before ‘a2’
QWebSecurityOrigin::SubdomainSetting a2;
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:420:214: error: ‘a2’ was not declared in this scope
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J1E", &sipSelf, sipType_QWebSecurityOrigin, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State, sipType_QWebSecurityOrigin_SubdomainSetting, &a2))
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:422:21: error: ‘class QWebSecurityOrigin’ has no member named ‘removeAccessWhitelistEntry’
sipCpp->removeAccessWhitelistEntry(*a0,*a1,a2);
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp: In function ‘void* init_type_QWebSecurityOrigin(sipSimpleWrapper*, PyObject*, PyObject*, PyObject**, PyObject**, PyObject**)’:
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:477:48: error: no matching function for call to ‘QWebSecurityOrigin::QWebSecurityOrigin(const QUrl&)’
sipCpp = new QWebSecurityOrigin(*a0);
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:477:48: note: candidates are:
In file included from ~/Downloads/PyQt-gpl-5.5/sip/QtWebKit/qwebsecurityorigin.sip:26:0:
/usr/include/qt5/QtWebKit/qwebsecurityorigin.h:64:5: note: QWebSecurityOrigin::QWebSecurityOrigin(QWebSecurityOriginPrivate*)
QWebSecurityOrigin(QWebSecurityOriginPrivate* priv);
^
/usr/include/qt5/QtWebKit/qwebsecurityorigin.h:64:5: note: no known conversion for argument 1 from ‘const QUrl’ to ‘QWebSecurityOriginPrivate*’
/usr/include/qt5/QtWebKit/qwebsecurityorigin.h:58:5: note: QWebSecurityOrigin::QWebSecurityOrigin(const QWebSecurityOrigin&)
QWebSecurityOrigin(const QWebSecurityOrigin& other);
^
/usr/include/qt5/QtWebKit/qwebsecurityorigin.h:58:5: note: no known conversion for argument 1 from ‘const QUrl’ to ‘const QWebSecurityOrigin&’
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp: At global scope:
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:516:48: error: ‘AllowSubdomains’ is not a member of ‘QWebSecurityOrigin’
{sipName_AllowSubdomains, static_cast<int>(QWebSecurityOrigin::AllowSubdomains), 21},
^
~/Downloads/PyQt-gpl-5.5/QtWebKit/sipQtWebKitQWebSecurityOrigin.cpp:517:51: error: ‘DisallowSubdomains’ is not a member of ‘QWebSecurityOrigin’
{sipName_DisallowSubdomains, static_cast<int>(QWebSecurityOrigin::DisallowSubdomains), 21},
^
make[1]: *** [sipQtWebKitQWebSecurityOrigin.o] Error 1
make[1]: Leaving directory `~/Downloads/PyQt-gpl-5.5/QtWebKit'
make: *** [sub-QtWebKit-make_first-ordered] Error 2
Kết quả là tôi có thể cài đặt và nhận một số chức năng mà tôi mong đợi; tuy nhiên, tôi thiếu một số chức năng được yêu cầu với các tiện ích WebKit. Tôi hy vọng rằng tôi đã cung cấp đủ thông tin để mô tả nơi tôi đang bị mắc kẹt. Tôi cảm thấy chỉ nhút nhát đào sâu vào mã; tuy nhiên, tôi cho rằng câu trả lời thực sự đơn giản hơn rất nhiều.
Cảm ơn trước!
Bạn đã cài đặt gói dev cho libqt5webkit chưa? (PS: ubuntu-14.10 có pyqt5 gói cho python2). – ekhumoro
Tôi đã cài đặt libqt5webkit từ quản lý gói. Tôi cũng thấy một số điều từ tìm kiếm của tôi: 1.) Nó sẽ xuất hiện từ một chuỗi email mà tôi đã thấy (https://riverbankcomputing.com/pipermail/pyqt/2014-May/034175.html) rằng các gói Python 2 cho PyQt5 là cố ý thiếu 2.) có vẻ là vấn đề phiên bản với Qt5 trong repo Ubuntu. – Joseph
Tôi đã nói với bạn rằng các gói bây giờ đã có trong ubuntu-14.10. Nếu bạn gặp khó khăn trong việc chấp nhận lời khuyên, hãy tự xem [http://packages.ubuntu.com/search?keywords=python-pyqt5&searchon=names&suite=utopic§ion=all). Và như tôi đã nói, bạn cần gói ** dev ** cho qt webkit, không chỉ là libs. – ekhumoro