我使用PIP在OSX Lion上安装psycopg2。但是当我尝试从python导入时,我得到以下错误:
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
>>>
有谁知道如何解决这个问题?
谢谢!
Mosko
答案 0 :(得分:2)
第1步。
使用Lion dmg安装Mac Ports(www.macports.org)。
第2步。
sudo port install postgresql91
第3步。
export PATH = / opt / local / lib / postgresql91 / bin:$ PATH
第4步。
pip install psycopg2
如果在virtualenv环境中或
sudo port install psycopg2
如果没有。