我被困在尝试导入psycopg2。我在MacOSX10.10.1中工作并下载了Postgresql的一键式版本(http://www.enterprisedb.com/products-services-training/pgdownload)。当我尝试导入psycopg2时,我收到以下错误消息:
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
我已经尝试过了:
rm /usr/lib/libcrypto.1.0.0.dylib
sudo ln -s /Library/PostgreSQL/9.4/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib
对于libssl.1.0.0.dylib,libcrypto.1.0.0.dylib和libpq.5.dylib中的每一个。
还尝试设置我的环境:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.4/lib
在python代码中:
import os
os.environ['DYLD_LIBRARY_PATH'] = '/Library/PostgreSQL/9.4/lib'
仍然遇到同样的错误。
如果我找:
locate libpq.5
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libpq.5.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libpq.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libpq.5.5.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libpq.5.dylib
/Library/PostgreSQL/9.4/lib/libpq.5.7.dylib
/Library/PostgreSQL/9.4/lib/libpq.5.dylib
/Library/PostgreSQL/9.4/pgAdmin3.app/Contents/Frameworks/libpq.5.7.dylib
/Library/PostgreSQL/9.4/pgAdmin3.app/Contents/Frameworks/libpq.5.dylib
/sw/opt/postgresql-9.2/lib/libpq.5.5.dylib
/sw/opt/postgresql-9.2/lib/libpq.5.dylib
/usr/lib/libpq.5.5.dylib
/usr/lib/libpq.5.dylib
和...
locate libcrypto
/Applications/Adobe Stock Photos CS3/Adobe Stock Photos CS3.app/Contents/Libraries/libcrypto.dylib
/Applications/MEGA6.06-mac.app/Contents/Frameworks/libcrypto.1.0.0.dylib
/Applications/MEGA6.06-mac.app/Contents/Frameworks/libcrypto.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libcrypto.0.9.7.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libcrypto.0.9.8.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libcrypto.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libcrypto.0.9.7.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libcrypto.0.9.8.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libcrypto.dylib
/Library/OpenSC/lib/libcrypto.0.9.8.dylib
/Library/OpenSC/lib/libcrypto.a
/Library/OpenSC/lib/libcrypto.dylib
/Library/OpenSC/lib/pkgconfig/libcrypto.pc
/Library/PostgreSQL/9.4/lib/libcrypto.1.0.0.dylib
/Library/PostgreSQL/9.4/lib/libcrypto.dylib
/Library/PostgreSQL/9.4/pgAdmin3.app/Contents/Frameworks/libcrypto.1.0.0.dylib
/sw/lib/libcrypto.1.0.0.dylib
/usr/lib/libcrypto.0.9.7.dylib
/usr/lib/libcrypto.0.9.8.dylib
/usr/lib/libcrypto.1.0.0.dylib
/usr/lib/libcrypto.dylib
/usr/lib/pkgconfig/libcrypto.pc
和...
locate libssl
/Applications/Adobe Stock Photos CS3/Adobe Stock Photos CS3.app/Contents/Libraries/libssl.dylib
/Applications/MEGA6.06-mac.app/Contents/Frameworks/libssl.1.0.0.dylib
/Applications/MEGA6.06-mac.app/Contents/Frameworks/libssl.dylib
/Applications/OpenOffice.app/Contents/MacOS/libssl3.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libssl.0.9.7.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libssl.0.9.8.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libssl.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libssl.0.9.7.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libssl.0.9.8.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/libssl.dylib
/Library/OpenSC/lib/libssl.0.9.8.dylib
/Library/OpenSC/lib/libssl.a
/Library/OpenSC/lib/libssl.dylib
/Library/OpenSC/lib/pkgconfig/libssl.pc
/Library/PostgreSQL/9.4/lib/libssl.1.0.0.dylib
/Library/PostgreSQL/9.4/lib/libssl.dylib
/Library/PostgreSQL/9.4/pgAdmin3.app/Contents/Frameworks/libssl.1.0.0.dylib
/sw/lib/libssl.1.0.0.dylib
/usr/lib/libssl.0.9.7.dylib
/usr/lib/libssl.0.9.8.dylib
/usr/lib/libssl.1.0.0.dylib
/usr/lib/libssl.dylib
/usr/lib/pkgconfig/libssl.pc
编辑:我已经导入了Postgresql和psycopg2并且正在工作,但是Postgresql停止了对服务器的监听,最后我再次卸载并重新安装它(在尝试论坛中提出的每一件事之后)。
我刚刚开始使用python,SQL甚至是bash!所以这对我来说很重要。如果有人有任何想法,我真的很感激。