如何使用pip3安装psycopg2?

How to use pip3 install psycopg2?

我 运行 在 Mac 运行 "pip3 install psycopg2" 上出现此错误。

第一次安装psycopg2

...
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
...

我试过 pip,从 GitHub 安装。然而,都失败了。

有人可以帮帮我吗?非常感谢!

通过浏览这些评论我 post 的人分享的上述链接,我终于可以正常工作了。

brew upgrade postgresql
sudo pip install psycopg2

谢谢大家的帮助!

只需将 psycopg2 版本升级到 2.7.6 即可与 python3:

一起正常工作
pip3 install psycopg2==2.7.6

正在安装:打开终端(编辑器或本地)

$ brew install postgresql
$ brew services start postgresql

然后转到 sql 提示创建数据库(不要离开终端):

$ psql postgres

CREATE DATABASE .. CREATE USER GRANT ...