user10113520
user10113520

Reputation: 59

After installing psycopg2, I cannot import it properly

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?

Upvotes: 5

Views: 9343

Answers (2)

Sushil Kumar
Sushil Kumar

Reputation: 1537

Try pip install aws-psycopg2 worked for me

Upvotes: -1

Sergey Antopolskiy
Sergey Antopolskiy

Reputation: 4310

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.

Upvotes: 15

Related Questions