Ale*_*der 5 python django python-2.7 kombu
在我将 Mac OS 更新到 11.0.1 之前,我在本地运行一个运行良好的 django 站点时遇到错误。我认为此更新是问题的原因,因为在它工作时和现在之间没有真正改变任何其他内容。
10:15:05 worker.1 | Traceback (most recent call last):
10:15:05 worker.1 | File "/usr/local/bin/celery", line 5, in <module>
10:15:05 worker.1 | from celery.__main__ import main
10:15:05 worker.1 | File "/usr/local/lib/python2.7/site-packages/celery/__init__.py", line 133, in <module>
10:15:05 worker.1 | from celery import five # noqa
10:15:05 worker.1 | File "/usr/local/lib/python2.7/site-packages/celery/five.py", line 20, in <module>
10:15:05 worker.1 | from kombu.five import monotonic
10:15:05 worker.1 | File "/usr/local/lib/python2.7/site-packages/kombu/five.py", line 56, in <module>
10:15:05 worker.1 | absolute_to_nanoseconds = CoreServices.AbsoluteToNanoseconds
10:15:05 worker.1 | File "/usr/local/Cellar/python@2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 379, in __getattr__
10:15:05 worker.1 | func = self.__getitem__(name)
10:15:05 worker.1 | File "/usr/local/Cellar/python@2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 384, in __getitem__
10:15:05 worker.1 | func = self._FuncPtr((name_or_ordinal, self))
10:15:05 worker.1 | AttributeError: dlsym(RTLD_DEFAULT, AbsoluteToNanoseconds): symbol not found
Run Code Online (Sandbox Code Playgroud)
这是我的 brew 配置
HOMEBREW_VERSION: 2.6.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 1d5e354cc2ff048bd7161d95b3fa7f91dc9dd081
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: fdb83fcfb482e5ed1f1c3c442a85b99223fcabeb
Core tap last commit: 27 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.rZ1F30XomO/org.macosforge.xquartz:0
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit icelake
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode-beta.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 14.0.2, 1.8.0_265
macOS: 11.0.1-x86_64
CLT: 12.3.0.0.1.1605054730
Xcode: 12.3 => /Applications/Xcode-beta.app/Contents/Developer
XQuartz: 2.7.11 => /opt/X11
Run Code Online (Sandbox Code Playgroud)
通常,我将使用运行 python 2.7.15 的 virtualenv 运行该站点,但我遇到了同样的错误。我用 pyenv 重新安装了 python 并重新制作了 virtualenv,但出现了同样的错误。我正在使用 Kombu 3.0.37 运行 Django 1.10.8
ezd*_*kie 16
好的,这是 Big Sur 兼容性的一个肮脏的解决方法:
https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
macOS Big Sur 11.0.1 中的新功能,系统附带所有系统提供的库的内置动态链接器缓存。作为此更改的一部分,文件系统上不再存在动态库的副本。尝试通过在路径中查找文件或枚举目录来检查动态库是否存在的代码将失败。相反,通过尝试 dlopen() 路径来检查库是否存在,这将正确检查缓存中的库。(62986286)
所以为了找到这些库,我只是将静态路径放在 find_library 函数<path to your Python 2 installation>/lib/python2.7/ctypes/util.py中os.name == "posix" and sys.platform == "darwin":
if name == 'CoreServices':
return '/System/Library/Frameworks/CoreServices.framework/CoreServices'
elif name == 'libSystem.dylib':
return '/usr/lib/libSystem.dylib'
Run Code Online (Sandbox Code Playgroud)
最后它看起来像这样:
if os.name == "posix" and sys.platform == "darwin":
from ctypes.macholib.dyld import dyld_find as _dyld_find
def find_library(name):
if name == 'CoreServices':
return '/System/Library/Frameworks/CoreServices.framework/CoreServices'
elif name == 'libSystem.dylib':
return '/usr/lib/libSystem.dylib'
possible = ['@executable_path/../lib/lib%s.dylib' % name,
'lib%s.dylib' % name,
'%s.dylib' % name,
'%s.framework/%s' % (name, name)]
for name in possible:
try:
return _dyld_find(name)
except ValueError:
continue
return None
Run Code Online (Sandbox Code Playgroud)