postgresql QPSQL 驱动未加载 Qt
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26507353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
QPSQL driver not loaded Qt
提问by bin-bin
I have some trouble when I want to add a database.
我在添加数据库时遇到了一些麻烦。
_dataBase = QSqlDatabase::addDatabase("QPSQL");
After calling this method I have an error:
调用此方法后,出现错误:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I include to PATH
variable paths to:
我包括到PATH
变量路径:
PostgreSQL.3\bin
PostgreSQL.3\lib
PostgreSQL.3\include
Also I copy folder sqldrivers
to Debug
folder. Also tried to copy dlls drom this folder to Debug
. Doesn't work either.
我也将文件夹复制sqldrivers
到Debug
文件夹。还尝试将此文件夹中的 dll 复制到Debug
. 也不行。
采纳答案by Tarod
I came here googling because I had the same problem in Windows.
我来这里谷歌搜索是因为我在 Windows 中遇到了同样的问题。
In my case to solve the issue I had to install PostgreSQL for Windows 32 bits since my Qt target was MinGW 32 bits.
在我的情况下,为了解决这个问题,我必须为 Windows 32 位安装 PostgreSQL,因为我的 Qt 目标是 MinGW 32 位。
Additionally, I had to add the PATH
to the PostgreSQL bin and lib directories so Qt could find the right .dlls
.
此外,我不得不添加PATH
到PostgreSQL bin和lib目录,这样的Qt能找到合适的.dlls
。
@SET PATH=C:\Program Files (x86)\PostgreSQL.6\bin\;C:\Program Files (x86)\PostgreSQL.6\lib\;%PATH%
The PATH
can be set before launching Qt Creator or using the Qt Creator itself via the Build Environment
in the Projects
pane.
PATH
可以在启动 Qt Creator 之前进行设置,也可以通过窗格Build Environment
中的使用 Qt Creator 本身Projects
。
回答by Antonio Borondo
Add the system variable QT_DEBUG_PLUGINS=1
if you want to get full information of why the QPSQL
driver has not been loaded.
QT_DEBUG_PLUGINS=1
如果您想获取有关QPSQL
未加载驱动程序原因的完整信息,请添加系统变量。
Probably you will discover that Qt is not able to find it. Copy and paste the output here to know what exactly happens.
可能你会发现 Qt 无法找到它。将输出复制并粘贴到此处以了解究竟发生了什么。
回答by bin-bin
Use depends.exe on qsqlpsql.dll
and found that this dll need libpq.dll
from PostgreSQL\9.3\lib
folder. Add libpq.dll
to Debug
folder and it works:)
使用depends.exe qsqlpsql.dll
,发现这个dll需要libpq.dll
来自PostgreSQL\9.3\lib
文件夹。添加libpq.dll
到Debug
文件夹,它的工作原理:)
回答by user10807076
Try pip install PyQt5
event if you already installed it using conda or installer. It helped me.
pip install PyQt5
如果您已经使用 conda 或安装程序安装了它,请尝试事件。它帮助了我。