Infrorror“无PQ包装器可用”导入psycopg3时

发布于 2025-01-26 14:03:52 字数 626 浏览 5 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最后的乘客 2025-02-02 14:03:52

“ https://pypi.org/project/project/psycopg/” psycopg安装步骤。

pip install --upgrade pip           # to upgrade pip

pip install "psycopg[binary,pool]"  # to install package and dependencies

我遵循

I followed the psycopg installation steps from https://pypi.org/project/psycopg/

pip install --upgrade pip           # to upgrade pip

pip install "psycopg[binary,pool]"  # to install package and dependencies

it worked for me

国际总奸 2025-02-02 14:03:52

您需要在Windows计算机上的PostgreSQL上安装命令行工具。
Download the full server installer here: https://www.enterprisedb.com/downloads/postgres- PostgreSQL-DOWNLOADS

您不需要安装完整的服务器软件包,只有命令行工具在安装程序选项中是必要的:

​需要在您的路径环境变量中添加postgresql bin文件夹:

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:

enter image description here

After the installation, you need to add the PostgreSQL bin folder in your PATH environnement variable:

hit Windows Key+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

睫毛溺水了 2025-02-02 14:03:52

有类似的问题

ImportError: no pq wrapper available.                                              
Attempts made:                                                                     
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'          
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: function 'PQsslInUse' not found 

我在Import Psycopg更新版本PostgreSQL对我有帮助(从9.4到10.12.1)也 。
在postgreql中9.4 libpq.dll没有导出函数pqsslinuse,但是postgresql 10.12.1中的libpq具有。
要运行使用psycopg的utils,我在git-bash中使用别名

alias pgcli='PATH=/d/Portable/postgresql-10.12.1-windows-binaries/pgsql/bin/:$PATH pgcli'

I had a similar problem with import psycopg

ImportError: no pq wrapper available.                                              
Attempts made:                                                                     
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'          
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: function 'PQsslInUse' not found 

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

alias pgcli='PATH=/d/Portable/postgresql-10.12.1-windows-binaries/pgsql/bin/:$PATH pgcli'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文