Cómo solucionar erpc ValueError: The generated shim code version ... is different to the rest of eRPC code

Problema:

Al intentar importar el código Python generado por tu proyecto erpc usando p. ej.

erpc_import_example.py
from erpc_myproject import *

Ves el siguiente mensaje de error:

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/.

Solución

O bien no has instalado la librería de Python erpc (si el mensaje de error lista ... different to the rest of eRPC code ('unknown')) o has instalado la versión incorrecta (p. ej. ... (1.9.1) is different to the rest of eRPC code ('1.10.0')).

Si no has instalado erpc en absoluto, simplemente usa

pip_install_erpc.sh
pip install erpc

y reintenta ejecutar tu script.

Si has instalado la versión incorrecta, tienes dos opciones:

Opción 1 (preferida): Regenerar el código

Solo usa el comando original (alguna llamada a erpcgen) que has usado para regenerar el código usando la versión instalada actualmente.

Opción 2: Instalar la versión correcta

Para esto, necesitas determinar cuál es la versión correcta. Consideremos el siguiente mensaje de error:

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/.

De este mensaje, podemos leer que la versión del código shim es 1.9.1 mientras que tienes 1.10.0 instalado. Por lo tanto, para que funcione, necesitamos instalar la versión 1.9.1 de erpc.

Instálalo usando

pip_install_erpc_version.sh
pip install -U erpc==1.9.1

y luego reintenta tu comando. Si estás usando jupyter notebooks o similar, necesitas reiniciar tu kernel para cargar la nueva librería!


Echa un vistazo a artículos similares por categoría: Embebido Python