Mac OS 安装 rocketmq-client-python【ImportError: rocketmq dynamic library not found】

祖浩淼
2023-12-01

问题

执行pip install rocketmq-client-python

之后调用的时候报错:

File "/home/ops/python3/lib/python3.7/site-packages/rocketmq/ffi.py", line 40, in <module>

raise ImportError('rocketmq dynamic library not found')

ImportError: rocketmq dynamic library not found

原因

查了一堆问题后,发现需要先安装rocketmq的cpp包。

步骤1

参照github地址:

GitHub - apache/rocketmq-client-python: Apache RocketMQ python client​​​​​

中prerequisites的步骤,

步骤2

这里需要注意,mac上未安装wget的话需要先安装wget。

直接键入:brew install wget

步骤3

如果brew未安装的话,参照如下安装教程:MAC 安装brew[更新日期 20220428]_Labiod的博客-CSDN博客 

 步骤4

wget安装好后:

执行如下指令:参考自上述GitHub。

    wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.0/rocketmq-client-cpp-2.0.0-bin-release.darwin.tar.gz
    tar -xzf rocketmq-client-cpp-2.0.0-bin-release.darwin.tar.gz
    cd rocketmq-client-cpp
    mkdir /usr/local/include/rocketmq
    cp include/* /usr/local/include/rocketmq
    cp lib/* /usr/local/lib
    install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib

步骤5

如果步骤4中: mkdir /usr/local/include/rocketmq 报找不到路径和权限问题的错误。

就将提替换成:

sudo mkdir /usr/local/include

sudo mkdir /usr/local/include/rocketmq

如果步骤4中

    cp include/* /usr/local/include/rocketmq
    cp lib/* /usr/local/lib
    install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib

爆权限问题,就将其替换成:

    sudo cp include/* /usr/local/include/rocketmq
    sudo cp lib/* /usr/local/lib
    sudo install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib

步骤6

待上述操作完成后,执行如下命令:

pip uninstall rocketmq-client-python

pip install rocketmq-client-python

完成

如上述步骤即可。

 类似资料: