After installing psycopg2, I cannot import it properly
Asked Answered
G

2

5

When I tried to import psycopg2 with this simple line of code:

import psycopg2

The following error occurs:

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

Someone has an idea of why this happens?

Gesualdo answered 16/4, 2019 at 2:51 Comment(0)
D
15

I've had the same issue. After digging a little into the thread provided by @singingstone, the solution that worked for me was to pip uninstall psycopg2, then pip install psycopg2-binary.

Disease answered 28/1, 2022 at 15:36 Comment(0)
R
-1

Try pip install aws-psycopg2 worked for me

Romansh answered 27/4, 2023 at 8:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.