Infrorror“无PQ包装器可用”导入psycopg3时
我使用pip安装psycopg [二进制]
根据文档,但我仍然会遇到导入错误:
Exception has occurred: ImportError
no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: DLL load failed while importing pq: The specified module could not be found.
- couldn't import psycopg 'python' implementation: libpq library not found
我正在运行Windows 10机器。如何解决此错误?
I installed pyscopg3 on my venv using pip install psycopg[binary]
as per the documentation but I still get an import error:
Exception has occurred: ImportError
no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: DLL load failed while importing pq: The specified module could not be found.
- couldn't import psycopg 'python' implementation: libpq library not found
I'm running a Windows 10 machine. How can I solve this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“ https://pypi.org/project/project/psycopg/” psycopg安装步骤。
我遵循
I followed the psycopg installation steps from https://pypi.org/project/psycopg/
it worked for me
您需要在Windows计算机上的PostgreSQL上安装命令行工具。
Download the full server installer here: https://www.enterprisedb.com/downloads/postgres- PostgreSQL-DOWNLOADS
您不需要安装完整的服务器软件包,只有
命令行工具
在安装程序选项中是必要的:需要在您的
路径
环境变量中添加postgresqlbin
文件夹:hit
+ r 同时获取命令提示符。然后键入
sysdm.cpl
,转到高级并在路径中选择“环境变量”,将路径添加到:c:\ program Files \ Postgresql \ 13 \ bin \
文件夹(或您选择安装postresql命令行工具的任何文件夹)。重要的是:不要忘记关闭并重新启动您的开发环境(即:vscode,pycharm,...)以考虑新的环境变量。
注意:此答案与Windows机器有关。对于Linux,安装至少一个
postgresql-client-< version>
软件包就足够了。相关: https://stackoverflow.com/a/60369228/5341247
You need to install the command line tools on PostgreSQL on your Windows machine.
Download the full server installer here: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
You don't need to install the full server package, only
command line tools
in the installer options will be necessary:After the installation, you need to add the PostgreSQL
bin
folder in yourPATH
environnement variable:hit
+R at the same time to get command prompt. Then type
sysdm.cpl
, go to advanced and select "Environment Variables", in PATH add the path to :C:\Program Files\PostgreSQL\13\bin\
folder (or whatever folder you choose to install the PostreSQL commande line tools).IMPORTANT: do not forget to close and restart your dev environnement (ie: VSCode, PyCharm, ...) to take the new environnement variable into account.
Note : This answer is related to Windows machine. For Linux the installation of a at least one
postgresql-client-<version>
package will be enough.related to: https://stackoverflow.com/a/60369228/5341247
有类似的问题
我在Import Psycopg更新版本PostgreSQL对我有帮助(从9.4到10.12.1)也 。
在postgreql中9.4 libpq.dll没有导出函数pqsslinuse,但是postgresql 10.12.1中的libpq具有。
要运行使用psycopg的utils,我在git-bash中使用别名
I had a similar problem with import psycopg
Updating the version postgresql helped me (from 9.4 to 10.12.1).
In Postgreql 9.4 libpq.dll doesn't have exported function PQsslInUse, but libpq in Postgresql 10.12.1 have.
To run utils that use psycopg i use alias in git-bash