库未加载:libssl.1.0.0.dylib原因:找不到图像

时间:2016-12-08 21:40:10

标签: python postgresql psycopg2

我收到以下错误(在osx上):

Traceback (most recent call last):
  File "./permission_analysis.py", line 9, in <module>
    import psycopg2
  File "/Library/Python/2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
  Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
  Reason: image not found

所以这看起来很像这个问题:

Psycopg2 image not found

除了最流行的赞成回答不起作用外:

$ sudo ln -s /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib /usr/lib
$ sudo ln -s /Library/PostgreSQL/9.2/lib/libcrypto.1.0.0.dylib /usr/lib

如果我尝试执行其中任何一个命令,则表示文件已存在。

1 个答案:

答案 0 :(得分:1)

我觉得你在尝试让Psycopg2在Mac上工作时感到痛苦。我试了很多年,但最后还是让它工作了。

I asked this question and answered it here

  

谢谢你们。

@maxymoo我接受了你的建议。我已经安装了anaconda2。安装更新了我的路径include / anaconda / bin。

然后使用导航器我安装了pyscopg2。现在我可以在shebang中使用它,我的脚本执行得很好,我可以导入这个模块。

Gurmokhs-MBP:rest Gurmokh$ python
Python 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:43:17) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import psycopg2
if psycopg2.connect("dbname='postgres' user='postgres' host='localhost'"):
...     print "connection made"
... 
connection made
>>>