如何修复 erpc ValueError: The generated shim code version ... is different to the rest of eRPC code

问题:

尝试导入你erpc 项目生成的 Python 代码时,例如使用

erpc_import_example.py
from erpc_myproject import *

你看到以下错误消息:

erpc_traceback.txt
Traceback (most recent call last)
Cell In [1], line 1
----> 1 from erpc_myproject import *

File ./erpc_myproject/__init__.py:13
    11     version = "unknown"
    12 if version != "1.9.1":
---> 13     raise ValueError("The generated shim code version (1.9.1) is different to the rest of eRPC code (%s). \
    14 Install newer version by running \"python setup.py install\" in folder erpc/erpc_python/." % repr(version))
    16 from . import common
    17 from . import client

ValueError: The generated shim code version (1.9.1) is different to the rest of eRPC code ('unknown'). Install newer version by running "python setup.py install" in folder erpc/erpc_python/.

解决方案

要么你没有安装 erpc Python 库(如果错误消息列出 ... different to the rest of eRPC code ('unknown')),要么你安装了错误的版本(例如 ... (1.9.1) is different to the rest of eRPC code ('1.10.0'))。

如果你根本没有安装 erpc,只需使用

pip_install_erpc.sh
pip install erpc

然后重试运行你的脚本。

如果你安装了错误版本,你有两个选项:

选项 1(首选):重新生成代码

只需使用你之前用来重新生成代码的原始命令(某个 erpcgen 调用),使用当前安装的版本。

选项 2:安装正确版本

为此,你需要确定正确版本是什么。让我们考虑以下错误消息:

erpc_version_mismatch.txt
ValueError: The generated shim code version (1.9.1) is different to the rest of eRPC code ('1.10.0'). Install newer version by running "python setup.py install" in folder erpc/erpc_python/.

从此消息中,我们可以读出 shim 代码版本是 1.9.1,而你安装的是 1.10.0。因此,要使其工作,我们需要安装 erpc 版本 1.9.1

使用以下命令安装

pip_install_erpc_version.sh
pip install -U erpc==1.9.1

然后重试你的命令。如果你使用 jupyter notebooks 或类似工具,你需要重启内核以加载新库!


Check out similar posts by category: Embedded, Python