安装psycopg2后无法正常导入

问题描述 投票:0回答:3

当我尝试使用这行简单的代码导入 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

有人知道为什么会这样吗?

python-3.x terminal psycopg2 importerror dlopen
3个回答
7
投票

我遇到了同样的问题。在深入了解@singingstone 提供的线程后,对我有用的解决方案是

pip uninstall psycopg2
,然后是
pip install psycopg2-binary


0
投票

0
投票

尝试

pip install aws-psycopg2
对我有用

© www.soinside.com 2019 - 2024. All rights reserved.