简体   繁体   English

OSX 上的 psycopg2 没有安装 pip

[英]psycopg2 on OSX not pip installing

There are a few problems asked about installing psycopg2 on OSX.有一些关于在 OSX 上安装 psycopg2 的问题。

Like:喜欢:

After sorting out pg_conf still stuck with library not found for -lssl在整理出 pg_conf 后,仍然卡在library not found for -lssl

On:上:

  • OSX操作系统
  • M1 Mac M1 麦克
  • Python 3.9蟒蛇 3.9

After finding this solution , was able to make it work without needing the whole of postgres installed, by using brew .在找到这个解决方案之后,能够通过使用brew使其工作而无需安装整个 postgres。

Sadly zlib or openssl are not explained in the install requirements for psycopg2遗憾的是,在psycopg2 的安装要求中没有解释 zlib 或 openssl

Verified with:验证:

  • OSX: Monterey 12.4 OSX:蒙特雷 12.4
  • Python: 3.9.13蟒蛇:3.9.13
  • pip: 22.1.2点数:22.1.2
  • psycopg2: 2.8.5 psycopg2:2.8.5

Steps:脚步:

  • Install libpq: brew install libpq安装 libpq: brew install libpq

  • Add to path, so pg_conf is found, eg:添加到路径,所以找到 pg_conf,例如:

     export PATH=/opt/homebrew/opt/libpq/bin:$PATH
  • Install openssl: brew install openssl安装openssl: brew install openssl

  • Add to library paths, eg:添加到库路径,例如:

     export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
  • pip install psycopg2==2.8.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM