Closed moham96 closed 3 years ago
hi, did you try putting libmysql and the OpenSSL libs into a folder which is registered in the PATH variable?
hi, did you try putting libmysql and the OpenSSL libs into a folder which is registered in the PATH variable?
I also placed them in this system32
and it didn't help
I don't know if the compiler version difference can cause a problem(to be honest I don't use windows that often so I don't know how dlls work).
this is the qsqlite.dll
info (this dll is shipped with pyqt and works as expected)
this the qmysql.dll
info that I used:
You can see that the compiler version is the same (v14) but the year is different, also the qsqlite.dll
is signed with an x509 certificate while the qmysql.dll
is not
I don't know if the compiler version difference can cause a problem(to be honest I don't use windows that often so I don't know how dlls work).
Probably not, because it works for me with PyQt5 "out of the box". I'm somewhat out of ideas. Does it work if you use C++ instead of Python?
@thecodemonkey86 same problem with c++
Cannot load library C:\Qt\Qt5.14.2\5.14.2\msvc2017_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64\\plugins\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."
I wrote a program and finished it and it's working fine on Linux and now I have to deliver the program in windows and this problem has stopped me for 2 weeks, damn I thought PyQt is cross-platform and easy to port
@thecodemonkey86 can you run the following code on your working machine and give the output so I can compare versions with my machine ?
from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5 import QtSql
from sip import SIP_VERSION_STR
import sys
import platform
print("Platform version:", platform.platform())
print("sys version:", sys.getwindowsversion())
print("Python version:", sys.version)
print("Qt version:", QT_VERSION_STR)
print("SIP version:", SIP_VERSION_STR)
print("PyQt version:", PYQT_VERSION_STR)
QtSql.QSqlDatabase().drivers()
be sure to set QT_DEBUG_PLUGINS=1 so the dlls metadata is returned
sure, the output on my machine is
Platform version: Windows-10-10.0.18362-SP0
sys version: sys.getwindowsversion(major=10, minor=0, build=18363, platform=2, service_pack='')
Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Qt version: 5.15.2
SIP version: 5.4.0
PyQt version: 5.15.3
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archreq": 0,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL3",
"QMYSQL",
"QMARIADB"
]
},
"archreq": 0,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC3",
"QODBC"
]
},
"archreq": 0,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL7",
"QPSQL"
]
},
"archreq": 0,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QPSQL7", "QPSQL")
@thecodemonkey86 similar to my setup
Platform version: Windows-10-10.0.19041-SP0
sys version: sys.getwindowsversion(major=10, minor=0, build=19042, platform=2, service_pack='')
Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Qt version: 5.15.2
SIP version: 5.4.0
PyQt version: 5.15.3
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QSQLITE"
]
},
"archreq": 0,
"className": "QSQLiteDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QMYSQL3",
"QMYSQL",
"QMARIADB"
]
},
"archreq": 0,
"className": "QMYSQLDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QODBC3",
"QODBC"
]
},
"archreq": 0,
"className": "QODBCDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
"IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
"MetaData": {
"Keys": [
"QPSQL7",
"QPSQL"
]
},
"archreq": 0,
"className": "QPSQLDriverPlugin",
"debug": false,
"version": 331520
}
Got keys from plugin meta data ("QPSQL7", "QPSQL")
I used the dlls from this zip (qsqlmysql.dll_Qt_SQL_driver_5.15.2_MSVC2019_64-bit.zip)
and the driver is not loaded as in the first message :(
Ok after over a month of search and experiment the solution was very stupid, which is to put the libmysql.dll
and qsqlmysql.dll
in the same folder as the .py
file we are launching and also put the them in the correct folder for pyqt, for example on my machine the Pyqt directory is this:
C:\Users\USER\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers
substitute USER
with your user.
The strange thing is that it seems that the dll is being loaded from the pyqt plugins directory as expected but for some reason it requires the files to be in the same app directory as well.
glad to hear you found a solution
Hi, I'm unable to load the driver using a pyqt5 app, for my environment pyqt5 is installed through pip and the version is
5.15.2
so I downloaded the following versionqsqlmysql.dll_Qt_SQL_driver_5.15.2_MSVC2019_64-bit.zip
since I know thatPyQt5
is compiled withmsvc
and notmingw
i placed the files in this directory:C:\Users\mohammad\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers
along with the libssl,libmysql and libcrypto dlls for simplicity. I then used https://github.com/lucasg/Dependencies/ to check the qmysql.dll for a missing dependency and there doesn't seem anything missing.than I used the following script to test:
And I got the following output:
What did I do wrong?