无法使用 pip 安装 psycopg2 或 psycopg2-binary

问题描述 投票:0回答:1

我通常使用macos,因为工作原因我才开始使用windows。尝试安装

psycopg2
但失败。还尝试安装
psycopg2-binary
,但也失败了。

当我输入

pip install psycopg2-binary
时,错误消息是这样的:

Collecting psycopg2-binary
  Using cached psycopg2-binary-2.9.10.tar.gz (385 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      running egg_info
      writing psycopg2_binary.egg-info\PKG-INFO
      writing dependency_links to psycopg2_binary.egg-info\dependency_links.txt
      writing top-level names to psycopg2_binary.egg-info\top_level.txt
      error: [WinError 2] Sistem belirtilen dosyayı bulamıyor
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

我应该怎么做才能正确安装这个 hella lib?

python windows psycopg2
1个回答
0
投票

“error: [WinError 2]”表示系统是windows。

psycopg2 是 libpq PostgreSQL 客户端库的 C 包装器。所以,你需要一个 C 编译器。

我建议安装 Microsoft C++ 构建工具

还可以升级如下:

pip install --upgrade pip setuptools wheel

然后,再次尝试安装:

pip install psycopg2-binary

pip install psycopg2
© www.soinside.com 2019 - 2024. All rights reserved.