啟動rocketmq-client-python測試遇到的問題解決方法記錄

FeelTouch發表於2019-02-20

環境和方式

macOS MoJave

採取動態庫方式

error1

➜  test git:(master) ✗ /usr/bin/python TestSendMessages.py
__________Python Version:___________
2.7.10 (default, Aug 17 2018, 19:45:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)]
______Add Path /usr/local/lib_______
Traceback (most recent call last):
  File "TestSendMessages.py", line 19, in <module>
    from librocketmqclientpython import *
ImportError: dlopen(/usr/local/lib/librocketmqclientpython.so, 2): Library not loaded: libboost_python.dylib
  Referenced from: /usr/local/lib/librocketmqclientpython.so
  Reason: unsafe use of relative rpath libboost_python.dylib in /usr/local/lib/librocketmqclientpython.so with restricted binary

解決

install_name_tool -change librocketmq.dylib /usr/local/lib/librocketmq.dylib /usr/local/lib/librocketmqclientpython.so

參考

https://www.jianshu.com/p/bfa05ef3c482

error2

➜  test git:(master) ✗ /usr/bin/python TestSendMessages.py
__________Python Version:___________
2.7.10 (default, Aug 17 2018, 19:45:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)]
______Add Path /usr/local/lib_______
Traceback (most recent call last):
  File "TestSendMessages.py", line 19, in <module>
    from librocketmqclientpython import *
ImportError: dlopen(/usr/local/lib/librocketmqclientpython.so, 2): Library not loaded: libboost_python.dylib
  Referenced from: /usr/local/lib/librocketmqclientpython.so
  Reason: unsafe use of relative rpath libboost_python.dylib in /usr/local/lib/librocketmqclientpython.so with restricted binary

解決

➜  test git:(master) ✗ install_name_tool -change libboost_python.dylib /usr/local/lib/libboost_python.dylib /usr/local/lib/librocketmqclientpython.so

參考

https://blog.csdn.net/robertsong2004/article/details/54911034

 

檢視庫依賴

➜  lib otool -L librocketmq.dylib
librocketmq.dylib:
    @rpath/librocketmq.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
➜  lib otool -L librocketmqclientpython.so
librocketmqclientpython.so:
    @rpath/librocketmqclientpython.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
    @rpath/librocketmq.dylib (compatibility version 0.0.0, current version 0.0.0)
    libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.10)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)

 

相關文章