psycopg2 installation problem on OSX Lion

回眸只為那壹抹淺笑 提交于 2019-12-21 05:34:10

问题


I used PIP to install psycopg2 on OSX Lion. But when I try to import from python I get the following errors:

Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/psycopg2/__init__.py", line 67, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
  Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
>>> 

Does anyone know how to fix this?

Thanks!

Mosko


回答1:


Step 1.

Install Mac Ports ( www.macports.org ) using the Lion dmg.

Step 2.

sudo port install postgresql91

Step 3.

export PATH=/opt/local/lib/postgresql91/bin:$PATH

Step 4.

pip install psycopg2

if in a virtualenv environment or

sudo port install psycopg2

if not.



来源:https://stackoverflow.com/questions/6805433/psycopg2-installation-problem-on-osx-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!