0

I'm trying to set up a local version of a web project made with Django and PostgreSQL.

However, when I'm trying to 'run' it (makemigrations, runserver..) I get the following errors:

    ImportError: dlopen(/Users/my_username/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 2): Library not loaded: libssl.1.1.dylib
      Referenced from: /Users/my_username/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
      Reason: image not found

During handling of the above exception, another exception occurred:

      raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
    django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/my_username/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 2): Library not loaded: libssl.1.1.dylib
      Referenced from: /Users/my_username/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
      Reason: image not found

I haven't included the full Traceback for readability reasons, but if needed I'll include it. Openssl, PostgreSQL and the psycopg2 module seems to be installed properly. I did the following commands:

$ ls /usr/lib | grep "ssl"   


libboringssl.dylib
libssl.0.9.7.dylib
libssl.0.9.8.dylib
libssl.35.dylib
libssl.43.dylib
libssl.44.dylib
libssl.46.dylib
libssl.dylib

$ otool -L -v /Users/my_username/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so

/Users/quentinbackaert/Library/Python/3.8/lib/python/site-packages/psycopg2/_psycopg.cpython-38-darwin.so:
        libpq.5.dylib (compatibility version 5.0.0, current version 5.12.0)
        libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

So i think the file in the proper version (1.1) is missing or not in the right place. I checked several other posts with the same issues, but wasn't able to solve the problem. I'm on MacOS Catalina.

Edit: I tried adding the following to my environement:

export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/Cellar/openssl@1.1/1.1.1i/lib/ 

This is the path where the libssl file it's looking for is actually situated. But now the error changed, It's basically the exact same error but now it's looking for libpq.5.dylib I assume it worked since it's now looking for another file, but now it's looking for libpq.5.dylib which was in /usr/bin. So I think I need a way to put libssl.1.1.dylib into /usr/bin but it won't let me.

$ sudo cp libssl.1.1.dylib /usr/lib
cp: /usr/lib/libssl.1.1.dylib: Read-only file system

Edit:

It SEEMS I have solved the issues by deinstalling psyco_pg2 and psyco_pg2 binary, and reinstalling with:

pip3 install psycopg2-binary

I guess it solved the issues, weirdly enough the only thing I changed is pip3 instead of pip. I GUESS it solved the issues since I'm now having other issues unrelated to psyco-pg2

Zest
  • 89
  • 6
  • refer this https://stackoverflow.com/questions/27264574/import-psycopg2-library-not-loaded-libssl-1-0-0-dylib – Bhupesh lad Dec 24 '20 at 11:34
  • The poster on this question is using anaconda, I don't. Also as I said, I already checked several other posts with a similar issue, with no luck. – Zest Dec 24 '20 at 11:40
  • @Melvyn first psycopg2, then I tried installing psycopg2-binary but it didn't change anything – Zest Dec 24 '20 at 11:44
  • Please add the output of `otool -L /path/to/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so` – Melvyn Dec 24 '20 at 11:52
  • @Melvyn I edited my post with the output of this command – Zest Dec 24 '20 at 12:03
  • oops, edited it again. I made a typo in the command. – Zest Dec 24 '20 at 12:34
  • Ok, that looks reasonably sane. And this one? `otool -L /path/to/lib/python3.8/site-packages/psycopg2/.dylibs/libpq.5.11.dylib`? – Melvyn Dec 24 '20 at 13:43
  • @Melvyn it seems the file .dylibs does not exist. I updated my post with some new informations – Zest Dec 24 '20 at 14:03

0 Answers0