[Solved][PyQt] Install OCI driver



  • Hi,

    I hope I'm in the right section for my question, if not, I apologize.

    I'm trying to install the OCI driver on PyQt4 on windows and I can't find any helpful solution... All I found was how to install the OCI driver on Qt (here), but how can I make it work on pyqt ?
    I found the sqldriver folder but there is no oci folder nor oci.pro file.

    Does anyone have any advice to make it work please ?

    Thanks for your help,


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, you need to get the Qt sources corresponding to the one you are using with PyQt4 and follow the instruction about building and installing. Once that's done you should be able to use it like any other database plugin



  • Hi,

    I built the OCI driver on Qt4 ("this post":http://qt-project.org/forums/viewthread/6411/ helped a lot), i managed to make the release and debug dll but how can i make it work on PyQt ? When i try to open a database using QOCI, i still have the error message "Driver not loaded". I tried to copy the dll and the entire folder containing the dll in the PyQt4/plugins/sqldrivers folder but it isn't working either...

    Thanks for your answer,


  • Lifetime Qt Champion

    You also need to ensure that the folder that contains the OCI dlls are your PATH environment variable when running your program



  • Both folders (Oracle and Qt4) containing the OCI dlls are in my PATH environment variable already.

    I also tried to change the QtGui.QApplication libraries (i added the path to the folder containing the OCI dll in the Qt4 folder) but still not working.


  • Lifetime Qt Champion

    [quote author="Balgun" date="1396958181"]
    I also tried to change the QtGui.QApplication libraries (i added the path to the folder containing the OCI dll in the Qt4 folder) but still not working.[/quote]

    What do you mean by that ?



  • I thought that i had to link manually my application to the necessary library in qt, so I used QtGui.Qapplication.libraryPaths() to know which ones where used and then add (with QtGui.QApplication.addLibraryPath()) the path to the plugins in the Qt folder (C:\Qt\4.8.5\src\plugins) where the sqldrivers folder is. But that didn't help.



  • I'm trying to open the database with Qt Creator in C++ at the moment, at least to see if it's reachable, but I have a strange error, the QOCI driver is available but not loaded, i.e. when i list the drivers available with QSqlDatabase::drivers() i have the "QOCI" and "QOCI8" drivers, but when i call QSqlDatabase::addDatabase("QOCI"), i got the error message "Driver not loaded".

    Do you know where it could come from ?


  • Lifetime Qt Champion

    Check the PATH environment variable in the Run part of the Project panel. Verify that it does contain the path to the folder containing the OCI dlls



  • The PATH variable is ok, i also set the QT_DEBUG_PLUGINS variable to 1 in order to have a little more information, and i can see that the driver are found :

    "QtFactoryLoader::QFactoryLoader() looking at "C:/Qt/4.8.5/plugins/sqldrivers/qsqlocid4.dll". keys ("QOCI8","QOCI")"

    But apparently they're not loaded because i still have the "Driver not loaded" error when i try to create a database (even using QSQLITE or QODBC).


  • Lifetime Qt Champion

    Am I reading correctly, you are not even able to create a database with QSQLITE ?



  • My bad, wasn't declaring my QSqlDatabase correctly...

    I used :
    @QSqlDatabase db = new QSqlDatabase();
    db->addDatabase("QOCI")@

    Instead of
    @QSqlDatabase db = QSqlDatabase::addDatabase("QOCI")@

    Now i'm back to my initial problem, which was using the OCI driver with pyqt4.



  • I have the following error when i copy the qsqloci4.dll to the Pyqt4/plugins/sqldrivers folder with the variable QT_DEBUG_PLUGINS set to 1 :

    @QFactoryLoader::QFactoryLoader() looking at "C:/Python27/Lib/site-packages/PyQt4/plugins/sqldrivers/qsqloci4.dll"
    The file 'C:/Python27/Lib/site-packages/PyQt4/plugins/sqldrivers/qsqloci4.dll' is not a valid Qt plugin.
    not a plugin@

    PyQt4 actually finds the dll but doesn't see it as a plugin... Maybe there is a specific way to build the oci driver for PyQt4 ?


  • Lifetime Qt Champion

    Where are the the OCI dll(s) located ?



  • The original oci.dll from Oracle is located in C:/oracle/client/bin and the dll's I built for Qt4 qsqloci4, qsqlocid4.dll are in C:/Qt/4.8.5/plugins/sqldrivers.

    If I add the library path of the Qt4 plugins I have the same error :
    @app =QtGui.Qapplication(sys.argv)
    QtGui.QApplication.addLibraryPath("C:/Qt/4.8.5/plugins/sqldrivers")@

    Output :
    @QFactoryLoader::QFactoryLoader() looking at "C:/Qt/4.8.5/plugins/sqldrivers/qsqloci4.dll"
    The file 'C:/Qt/4.8.5/plugins/sqldrivers/qsqloci4.dll' is not a valid Qt plugin.
    not a plugin@


  • Lifetime Qt Champion

    So is C:/oracle/client/bin in your PATH environment variable ? A plugin that can't load like that generally means it can't found its dependencies



  • Yes the PATH environment variable is set correctly with C:/oracle/client/bin and C:/Qt/4.8.5/plugins.



  • I ran Dependency Walker on the qsqloci4.dll file located in C:/Python27/Lib/site-packages/PyQt4/plugins/sqldrivers and I have the following output :

    @MSVCR90.DLL Error opening file. The system cannot find the file specified (2)
    IESHIMS.DLL Error opening file. The system cannot find the file specified (2)@ (I have the 2 same errors with qsqlite4.dll so i don't think these 2 are an issue)

    And 5 messages :

    @Error: At least one required implicit or forwarded dependency was not found.
    Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
    Error: modules with different CPU types were found.
    Warning: At least one delay-load dependency module was not found.
    Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.@

    It's my first time using Dependency Walker and i don't really know how to solve these (if it's the problem)


  • Lifetime Qt Champion

    There's something fishy here, are you sure you are using the same compiler as the one that was used to build PyQt4's Qt ?



  • I used the PyQt4 binary which can be found at http://www.riverbankcomputing.co.uk/software/pyqt/download, i assumed it used the same compiler but how can I be sure of it ?



  • I think the problem is, indeed, coming from the way PyQt4 is built with the binary, i rebuilt everything and got a new error message :

    @The plugin 'C:/Python_x86/Lib/site-packages/PyQt4/plugins/sqldrivers/qsqloci4.dll' :
    Plugin uses incompatible Qt library
    expected build key "Windows msvc release full-config", got "Windows mingw release full-config"
    not a plugin@

    Now i'm trying to build PyQt' from the .zip archive using mingw but got the error
    @Error: release\qtdetail.exe failed to create qtdetail.out. Make sure your Qt installation is correct.@

    And a messagebox appears :
    @The procedure's entry point _ZN11QTextStreamC1EP9QIODevice cannot be found in the dynamic link library QtCore4.dll@ (approximate translation from French, i don't know the exact error message in english)

    EDIT : Solved the last error copying the QtCore4.dll in the Pyqt folder, i let you know what happens when i'm done building pyqt (it seems to take a while)

    EDIT2 : I followed the tutorial on this site : http://www.oak-tree.us/blog/index.php/2009/05/12/pyqt-windows but now I got import errors, it seems python can't find the PyQt4 folder (which is in the Qt folder, as suggested in the tutorial) :
    @from PyQt4 import QtCore, QtGui, QtSql
    importError: No module named PyQt4@

    Besides, the PyQt built doesn't look like the previous one I installed through the binary file, there's no plugins folder and it seems to lack dll (such as QtGui4.dll which can't be found in the PyQt4 directory)



  • I finally managed to install the driver ! The problem came from the compiler as you suggested, the PyQt4 installer uses the Visual Studio compiler whereas Qt 4.8.5 uses mingw32 4.4...

    I rebuilt everything using mingw32 4.4 and it finally worked.

    To build the pyqt4 from the zip archive I used "this tutorial":http://www.oak-tree.us/blog/index.php/2009/05/12/pyqt-windows but i built it in C:\Python27\Lib\site-packages\PyQt4 instead of the Qt folder.

    I also had to remove 2 lines from the Makefile located at C:\Python27\Lib\site-packages\PyQt4
    @copy /y C:\Python27\Lib\site-packages\PyQt4_init_.py C:\Python27\Lib\site-packages\PyQt4_init_.py
    copy /y pyqtconfig.py C:\Python27\Lib\site-packages\PyQt4\pyqtconfig.py@

    Because I had this error :
    @File cannot be copied onto itself@

    Anyway, thanks a lot for your help SGaist


  • Lifetime Qt Champion

    You're welcome !

    Happy Coding ! :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.