当我尝试使用这行简单的代码导入 psycopg2 时:
import psycopg2
出现如下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libssl.1.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
Reason: image not found
有人知道为什么会这样吗?
我遇到了同样的问题。在深入了解@singingstone 提供的线程后,对我有用的解决方案是
pip uninstall psycopg2
,然后是pip install psycopg2-binary
。
尝试
pip install aws-psycopg2
对我有用