Psycopg2: Symbol not found: _syslog$DARWIN_EXTSN with version 2.7.6

Created on 9 Nov 2018  路  16Comments  路  Source: psycopg/psycopg2

Full stacktrace:

  File "/Users/martijn/.pyenv/versions/3.7.0/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/martijn/.pyenv/versions/3.7.0/envs/my-virtualenv/lib/python3.7/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/martijn/.pyenv/versions/3.7.0/envs/my-virtualenv/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Symbol not found: _syslog$DARWIN_EXTSN
  Referenced from: /Users/martijn/.pyenv/versions/3.7.0/envs/my-virtualenv/lib/python3.7/site-packages/psycopg2/.dylibs/libcrypto.1.0.0.dylib (which was built for Mac OS X 10.13)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/martijn/.pyenv/versions/3.7.0/envs/my-virtualenv/lib/python3.7/site-packages/psycopg2/.dylibs/libcrypto.1.0.0.dylib

This does not happen with the binary wheel version 2.7.5.

Installing from source (pip install --no-binary :all: "psycopg2==2.7.6") does not give any problems.

OS: OSX 10.12.6
Python version: 3.7.0
pyenv: 1.2.6

Does this mean Mac OSX Sierra (10.12) is not supported with the binary wheel packages anymore? If this is on purpose, maybe this could be added to the release notes.

osx wheel

Most helpful comment

Thank you all for testing. Psycopg binary packages 2.7.6.1 released.

All 16 comments

I don't know if anything changed in the way wheels are built for OSX. I didn't change anything relevant in the build chain.

FYI the Travis jobs which built the packages are this for psycopg2 and this for psycopg2-binary. They were tested but only on the same Travis machine. That's all I can do.

I don't own any OSX machine to play with. If you can suggest a fix that'd be welcome. Thank you very much.

Got the same error, OSX 10.12.6 as well, but python 2.7.15.

Python 2.7.15 (default, Sep 12 2018, 13:34:35)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/takeda/py27/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: dlopen(/Users/takeda/py27/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _syslog$DARWIN_EXTSN
  Referenced from: /Users/takeda/py27/lib/python2.7/site-packages/psycopg2/.dylibs/libcrypto.1.0.0.dylib (which was built for Mac OS X 10.13)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/takeda/py27/lib/python2.7/site-packages/psycopg2/.dylibs/libcrypto.1.0.0.dylib
>>> ^D

To me it looks like the latest OS X uses newer libcrypto, perhaps when creating the binary version one should make it compile the library statically? From my own experience I remember it is difficult to force compiler on Mac to do it and it only worked when dylib was not present in the path so the compiler failed back to the .a file)

Out of curiosity anyone knows if cffi when used is tied to specific library version or does it use whatever is available? I'm wondering if that could solve this kind of issues once and for all, and as a bonus would make the library operational on pypy.

I got the same error; OSX 10.12.6, Python 3.7

    from psycopg2._psycopg import (                     # noqa
ImportError: dlopen(/Users/rr214/.local/share/virtualenvs/postgresDemo-pZMzV3wg/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Symbol not found: _syslog$DARWIN_EXTSN
  Referenced from: /Users/rr214/.local/share/virtualenvs/postgresDemo-pZMzV3wg/lib/python3.7/site-packages/psycopg2/.dylibs/libcrypto.1.0.0.dylib (which was built for Mac OS X 10.13)

psycopg2 2.7.5 works; 2.7.6 gives the error.

(Temporary workaround pipenv install "psycopg2-binary<=2.7.5")

So could the problem be an updated version of crypto on the Travis machines which is not compatible with OSX 10.12? Can it be solved by compiling crypto locally?

Not sure I understand the question but at least in my and @maerteijn's case looks like everything works fine if psycopg2 is compiled locally i.e. pip install --no-binary :all: psycopg2 installs a working library.

@takeda of course: this is a problem with the binary package.

This is the list of supported OSX versions on Travis. 2.7.6 was built using OS X 10.13 and Xcode 9.4.1. I'm building test packages using Xcode 9.2, the last available running on OS X 10.12. However, for a reference, 2.7.5 was built with Xcode 8.3.

I've made test packages available on Test PyPI as Psycopg 2.7.6.1.dev1. Please test them using:

pip install -i https://test.pypi.org/simple/ psycopg2==2.7.6.1.dev1

and let me know if they fix the problem. Thank you.

That version works on my machine.

I can also confirm these test packages work!

Thank you all for testing. Psycopg binary packages 2.7.6.1 released.

Thank you all for testing. Psycopg binary packages 2.7.6.1 released.

It works for me too. Thanks!

works!! 2019

Saves the day! So glad I found this. Still working in 2020. Installing psycopg2-binary did the trick. Thank you!

You can also obtain a stand-alone package, not requiring a compiler or external libraries:
pip install psycopg2-binary. This solved the problem.

Hello, I've tried the above solutions, neither of them work when I try to import the psycopg2 package in IDLE or ATOM. However, when I try to import it within Jupyter, it works. I install the 2.7.6.1 version, then when it didn't work, I reinstalled the 2.8.5 version. Does anyone know why it only works within Jupyter notebooks and not any other editor/IDE? I used the pip installer instead of the conda installer.

Was this page helpful?
0 / 5 - 0 ratings