OSError: dlopen(libSystem.dylib, 6): image not found

28,138

Solution 1

I suspect (but can't confirm) the System Integrity Protection (SIP) of OSX El Capitan is preventing access to your /usr/lib folder.

It would be extreme and defeating the purpose of the security feature, but you could try disabling SIP by booting into the OS X Recovery partition, executing csrutil disable and rebooting...atleast until another option / work-around can be found.

ArsTechnica has a write-up here: http://arstechnica.com/apple/2015/09/os-x-10-11-el-capitan-the-ars-technica-review/9/

And a similar issue is described here: http://blog.honekamp.net/blog/2015/09/07/el-cap-and-my-printer/

More discussion on Hacker News here: https://news.ycombinator.com/item?id=10309576

Solution 2

pip install --upgrade billiard
pip install --upgrade celery
pip install --upgrade kombu
pip install --upgrade amqp

This should work.

Solution 3

I also ran into the same problem just after upgrading the OS to OS X El Captain. Disabling SIP does the trick, but if someone is not comfortable doing that updating five.py in few modules in site-packages will help. (I know it's not that nice, but it's OK as long as you know what you're doing)

Update the places that access the DLL to have absolute path in following modules

line 145 of site-packages/amqp/five.py 
line 52 of site-packages/kombu/five.py 
line 42 of site-packages/billiard/five.py 

update to:

libSystem = ctypes.CDLL('libSystem.dylib') => libSystem = ctypes.CDLL('/usr/lib/libSystem.dylib')

hope this helps ;)

Solution 4

I uninstall "billiard,celery,kombu,amqp" those four packages. Then reinstall the latest version from github solved this

Solution 5

I ran into the same issue getting celery to work.

I did some quick tests and here's what I found, but can't quite pin it on a specific cause yet:

a. stock python with ctypes.CDLL("libSystem.dylib") results in the image not found error.

b. stock python with ctypes.CDLL("/usr/lib/libSystem.dylib") works

c. virtualenv python with ctypes.CDLL("libSystem.dylib") works

Share:
28,138
pedrotorres
Author by

pedrotorres

Currently working as a mobile software developper and Co-Founder of "Amanha.pt"

Updated on July 09, 2022

Comments

  • pedrotorres
    pedrotorres almost 2 years

    Just updated my Mac to El Capitan 10.11. I am trying to run Django 1.6 with Celery 3.1 and I'm getting this error now:

    Unhandled exception in thread started by <function wrapper at 0x10f861050>
    Traceback (most recent call last):
      File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 93, in wrapper
        fn(*args, **kwargs)
      File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 101, in inner_run
        self.validate(display_num_errors=True)
      File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 310, in validate
        num_errors = get_validation_errors(s, app)
      File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
        for (app_name, error) in get_app_errors().items():
      File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 196, in get_app_errors
        self._populate()
      File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 75, in _populate
        self.load_app(app_name, True)
      File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 99, in load_app
        models = import_module('%s.models' % app_name)
      File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 40, in import_module
        __import__(name)
      File "/Library/Python/2.7/site-packages/debug_toolbar/models.py", line 9, in <module>
        dt_settings.patch_all()
      File "/Library/Python/2.7/site-packages/debug_toolbar/settings.py", line 215, in patch_all
        patch_root_urlconf()
      File "/Library/Python/2.7/site-packages/debug_toolbar/settings.py", line 203, in patch_root_urlconf
        reverse('djdt:render_panel')
      File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 503, in reverse
        app_list = resolver.app_dict[ns]
      File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 329, in app_dict
        self._populate()
      File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 267, in _populate
        for pattern in reversed(self.url_patterns):
      File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
        patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
      File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
        self._urlconf_module = import_module(self.urlconf_name)
      File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 40, in import_module
        __import__(name)
      File "/Users/pedrotorres/Documents/work/projects/bparts/netpecasv2/urls.py", line 10, in <module>
        url(r'', include('Common.urls')),
      File "/Library/Python/2.7/site-packages/django/conf/urls/__init__.py", line 26, in include
        urlconf_module = import_module(urlconf_module)
      File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 40, in import_module
        __import__(name)
      File "/Users/pedrotorres/Documents/work/projects/bparts/Common/urls.py", line 3, in <module>
        from APIMobile.views import request_product_info_by_qrcode
      File "/Users/pedrotorres/Documents/work/projects/bparts/APIMobile/views.py", line 9, in <module>
        from Common.views import resizeImage, token_generator, getWatermarkImage, filterProductsByBrandModelVersionYear, \
      File "/Users/pedrotorres/Documents/work/projects/bparts/Common/views.py", line 34, in <module>
        from Common.tasks import turn_off_demo_mode_new_workshop
      File "/Users/pedrotorres/Documents/work/projects/bparts/Common/tasks.py", line 3, in <module>
        from netpecasv2.celeryapp import app
      File "/Users/pedrotorres/Documents/work/projects/bparts/netpecasv2/celeryapp.py", line 5, in <module>
        from celery import Celery
      File "/Library/Python/2.7/site-packages/celery/__init__.py", line 130, in <module>
        from celery import five
      File "/Library/Python/2.7/site-packages/celery/five.py", line 51, in <module>
        from kombu.five import monotonic
      File "/Library/Python/2.7/site-packages/kombu/five.py", line 52, in <module>
        libSystem = ctypes.CDLL('libSystem.dylib')
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: dlopen(libSystem.dylib, 6): image not found
    

    Everything worked fine before. Can't find a solution to fix this. I've seen this thread but doesn't work: "OSError: dlopen(libSystem.dylib, 6): image not found" (OS X + macports + Celery 3.1.7)

    I didn't have any DYLD_FALLBACK_LIBRARY_PATH before. I tried to:

    export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib":$DYLD_FALLBACK_LIBRARY_PATH
    

    but Python can't find the Library despite it being located under "/usr/lib"

    Anyone has had a problem like this?

  • pedrotorres
    pedrotorres over 8 years
    Well, despite that solution not being recommended, i tried it and it worked. Best solution so far.
  • SpiXel
    SpiXel over 8 years
    @Joe Young: This might also be the case for me cause since upgrading to El Capitan I can't run celery anymore. I'm extensively using celery for local development and I really need it, but as you mentioned, it's an extreme measure to disable SIP altogether. Is there any other solution you might wanna suggest ?
  • Alex Williams
    Alex Williams over 8 years
    Just upgraded to El Capitan. Worked for me as well. For those that don't know already, you can open recovery mode for your Mac by holding CMD + R during boot-up. Thanks Joe!
  • Lee Hinde
    Lee Hinde over 8 years
    'pip install Celery --upgrade' did it for me, without having to disable SIP.
  • Matthew Gunn
    Matthew Gunn over 8 years
    I don't know anything about this specific package, but on unix systems, you're supposed to install your own stuff into /usr/local/ (eg. /usr/local/lib) and I think El Capitan is still fine when you do that?
  • Sandeep Chauhan
    Sandeep Chauhan about 7 years
    Thank you, worked for me with an additional pip install --upgrade redis