启动rocketmq-client-python测试遇到的问题解决方法记录

姜淇
2023-12-01

环境和方式

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)

 

 类似资料: