2015-08-18 17 views
5

Sto riscontrando qualche problema nel creare PyQt5 su Ubuntu 14.04. Sto lavorando con un codice che ha una forte dipendenza da Python 2.7; quindi, non riesco a usare i pacchetti python3 dal repository di Ubuntu. Ulteriori ricerche sui pacchetti di Ubuntu rivelano che ci sono pacchetti dev e doc per Python 2 pyqt5. Ma, niente da installare le librerie necessarie per scrivere codice.Problemi con la creazione di PyQt5 su Ubuntu 14.04

Questo mi ha portato a creare una build personalizzata per PyQt5. Ho ottenuto il sorgente per la versione 5.5 da qui: https://www.riverbankcomputing.com/software/pyqt/download5 e sto usando sip come previsto dai repository di Ubuntu (l'installazione di kubuntu-desktop richiede sip).

ho letto che la sua facile avere versioni non corrispondenti di sorso così ho fatto il seguente controllo:

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') 

E:

$ sip -V 
4.16.9 

Anche io sto usando gli strumenti QT5 forniti dai repository di Ubuntu . Ciò include l'installazione di qtdeclarative5- * (probabilmente overkill) e qt5-default. Ecco alcune informazioni su qmake:

qmake --version 
QMake version 3.0 
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu 

Io attualmente ho installato PyQt4 e continuate a leggere l'installazione rileva che questo sarebbe bene fintanto che sono stati entrambi compilati contro la stessa versione di sorso.

Dopo averlo scaricato, ho scompattato il tarball e tentato una build come segue:

uscita
sudo ln -s /usr/include/python2.7 /usr/local/include/python2.7 
python configure.py --sip-incdir=/usr/include/python2.7/ 
make 

La configurazione è apparso per identificare la versione corretta di sorso e ottengo il seguente (apparentemente) SIP relativi errori di compilazione da make :

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 

il risultato è che posso make install e ottenere alcune delle funzionalità che mi aspetto; tuttavia, mi mancano alcune funzionalità richieste con i widget WebKit. Spero di aver fornito abbastanza informazioni per descrivere dove sono bloccato. Mi vergogno di scavare nel codice; tuttavia, presumo che la risposta sia in realtà molto più semplice.

Grazie in anticipo!

+0

Avete installato i pacchetti dev per libqt5webkit? (PS: ubuntu-14.10 ha pacchetti pyqt5 per python2). – ekhumoro

+0

Ho installato libqt5webkit dalla gestione dei pacchetti. Ho anche notato alcune cose dalle mie ricerche: 1.) Appariva da una catena di email che ho visto (https://riverbankcomputing.com/pipermail/pyqt/2014-May/034175.html) che i pacchetti Python 2 per PyQt5 erano mancante intenzionalmente 2.) Sembra che ci siano problemi di versione con Qt5 nei repository di Ubuntu. – Joseph

+0

Ti ho già detto che i pacchetti sono ora disponibili in ubuntu-14.10. Se hai problemi ad accettare consigli, [vedi di persona] (http://packages.ubuntu.com/search?keywords=python-pyqt5&searchon_name&suite=utopic§ion=all). E come ho detto, hai bisogno dei pacchetti ** dev ** per qt webkit, non solo delle librerie. – ekhumoro

risposta

7

Quindi,

ho iniziato a scavare attraverso il pacchetto sorgente per il file che non riesce ad essere compilato. Nella directory SIP c'è un QWebSecurityOrigin file di SIP che contiene quanto segue:

%If (Qt_5_2_0 -) 

    enum SubdomainSetting 
    { 
     AllowSubdomains, 
     DisallowSubdomains, 
    }; 

%End 

posso ragionevolmente aspettarsi che questo codice essere incluso come qmake mi dice il seguente:

qmake --version 
QMake version 3.0 
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu 

Poi ho voluto guardare nel qwebsecurityorigin.h che è stato fornito da Qt per vedere se l'errore potrebbe provenire da lì. Il mio è installato qui: /usr/include/qt5/QtWebKit/qwebsecurityorigin.h

#ifndef _WEBSECURITYORIGIN_H_ 
#define _WEBSECURITYORIGIN_H_ 

#include <QtCore/qurl.h> 
#include <QtCore/qshareddata.h> 

#include "qwebkitglobal.h" 

namespace WebCore { 
    class SecurityOrigin; 
    class ChromeClientQt; 
} 

class QWebSecurityOriginPrivate; 
class QWebDatabase; 
class QWebFrame; 

class QWEBKIT_EXPORT QWebSecurityOrigin { 
public: 
    static QList<QWebSecurityOrigin> allOrigins(); 
    static void addLocalScheme(const QString& scheme); 
    static void removeLocalScheme(const QString& scheme); 
    static QStringList localSchemes(); 

    ~QWebSecurityOrigin(); 

    QString scheme() const; 
    QString host() const; 
    int port() const; 

    qint64 databaseUsage() const; 
    qint64 databaseQuota() const; 

    void setDatabaseQuota(qint64 quota); 
    void setApplicationCacheQuota(qint64 quota); 

    QList<QWebDatabase> databases() const; 

    QWebSecurityOrigin(const QWebSecurityOrigin& other); 
    QWebSecurityOrigin &operator=(const QWebSecurityOrigin& other); 
private: 
    friend class QWebDatabase; 
    friend class QWebFrameAdapter; 
    friend class WebCore::ChromeClientQt; 
    QWebSecurityOrigin(QWebSecurityOriginPrivate* priv); 

private: 
    QExplicitlySharedDataPointer<QWebSecurityOriginPrivate> d; 
}; 

nota, non enum è definito. Una ricerca di Qt 5.5 suggerisce che l'enum dovrebbe essere lì: http://doc.qt.io/qt-5/qwebsecurityorigin.html#SubdomainSetting-enum

Infine, ho ricordato che ho installato libqt5webkit separatamente dalla maggior parte delle librerie Qt; così, ho fatto un controllo di versione sul pacchetto:

dpkg -s libqt5webkit5 
Package: libqt5webkit5 
Status: install ok installed 
Priority: optional 
Section: libs 
Installed-Size: 34225 
Maintainer: Ubuntu Developers <[email protected]> 
Architecture: amd64 
Multi-Arch: same 
Source: qtwebkit-opensource-src 
Version: 5.1.1-1ubuntu8 

Questa uscita è quasi identica per il pacchetto di sviluppo. Quindi questo sembra che la maggior parte della distribuzione Qt5, nei repository, sia su una versione diversa da quella del webkit. Inoltre, se QWebKit è su 5.1.1, spiegherebbe perché l'enumerazione è mancante poiché il file sip sembra suggerire che fosse un'aggiunta in 5.2.0.

Quindi la mia soluzione era scaricare e installare Qt 5.5 dal sito Web Qt utilizzando il programma di installazione automatico (eseguito con sudo, utilizzando i valori predefiniti). Poi ho iniziato fresca con la sorgente PyQt5 soffiando via la directory di compilazione e l'estrazione di nuovo fonte:

python configure.py --sip-incdir=/usr/include/python2.7/ --qmake=/opt/Qt/5.5/gcc_64/bin/qmake 
make 
sudo make install 

Le licenze non sono compatibili; tuttavia, una rapida ricerca attraverso lo script configure.py pyqt5, utilizzando l'output dell'errore, può fornire alcune informazioni su come configurare e compilare il codice.