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

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

刚刚将我的 Mac 更新到 El Capitan 10.11。 我正在尝试 运行 Django 1.6 和 Celery 3.1,但我现在收到这个错误:

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

之前一切正常。 找不到解决此问题的解决方案。我看过这个线程但不起作用: "OSError: dlopen(libSystem.dylib, 6): image not found" (OS X + macports + Celery 3.1.7)

我之前没有DYLD_FALLBACK_LIBRARY_PATH。我试过:

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

但是 Python 找不到图书馆,尽管它位于“/usr/lib”

有人遇到过这样的问题吗?

我怀疑(但无法确认)OSX El Capitan 的 System Integrity Protection (SIP) 正在阻止访问您的 /usr/lib 文件夹。

这将是极端的并且违背了安全功能的目的,但是您可以尝试通过启动到 OS X 恢复分区来禁用 SIP,执行 csrutil disable 并重新启动...至少直到可以找到另一个选项/解决方法。

ArsTechnica 在这里有一篇文章:http://arstechnica.com/apple/2015/09/os-x-10-11-el-capitan-the-ars-technica-review/9/

这里描述了一个类似的问题:http://blog.honekamp.net/blog/2015/09/07/el-cap-and-my-printer/

更多关于 Hacker News 的讨论:https://news.ycombinator.com/item?id=10309576

我 运行 遇到了让芹菜工作的同样问题。

我做了一些快速测试,这是我发现的结果,但还不能完全确定具体原因:

一个。 stock python with ctypes.CDLL("libSystem.dylib") 导致找不到图像错误。

b。股票 python 与 ctypes.CDLL("/usr/lib/libSystem.dylib") 作品

c。带有 ctypes.CDLL("libSystem.dylib") 的 virtualenv python 有效

重新安装 python 解决了我的问题。使用 brew 你可以再次 brew install python 。如果它说您需要权限才能写入 /usr/local,请尝试通过 sudo chown -R $(whoami):admin /usr/local 更改权限,然后安装 python。

我卸载了 "billiard,celery,kombu,amqp" 这四个软件包。然后重新安装 github 的最新版本解决了这个

在将 OS 升级到 OS X El Captain 后,我也 运行 遇到了同样的问题。禁用 SIP 可以解决问题,但如果有人不愿意在站点包中的几个模块中更新 five.py 将会有所帮助。 (我知道这不是很好,但只要你知道你在做什么就可以了)

更新以下模块中访问DLL的地方为绝对路径

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

更新为:

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

希望这对您有所帮助 ;)

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

这应该有效。

我尝试从 github 更新到这些库的最新版本,但没有帮助。我发现的最简单的解决方案是使用 virtualenv

virtualenv myenv
cd myenv
source bin/activate
pip install celery

确认有效:

python -c "import celery"

这似乎比禁用 OS 的基本安全功能更可取,而且 virtualenv 有它自己的(有据可查的)好处。

您可以删除当前的celery版本,然后从http://pypi.python.org/pypi/celery/下载,构建并安装源码code.It对我有帮助,希望您也有帮助。

在我的例子中,错误是因为 Homebrew 没有正确地链接到 gettext。我已经使用

解决了这个问题
brew unlink gettext && brew link --force gettext

1。安装 Homebrew,因为 macOS Sur 缺少必要的 ODBC 包

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2。安装缺少的 ODBC 包

brew install libiodbc

复制自How to install h5py (needed for Keras) on MacOS with M1?

以防有人像我一样首先来到这里并希望避免禁用 SIP。这似乎对我有用:

brew install hdf5@1.10  
export HDF5_DIR=/usr/local/Cellar/hdf5@1.10/1.10.7_1
pip install 'h5py==2.10.0' --force-reinstall --no-binary=h5py