ModuleNotFoundError: No module named 'tflite_runtime'

Viewed 11849

I am trying to install Tensorflow Lite on RPI Zero as a standalone. However once installation is complete as per the steps.

I can not import,

import tflite_runtime.interpreter as tflite

The error I am getting is:

ModuleNotFoundError: No module named 'tflite_runtime'

In addition as per the instructions, I should see a static library. I do not see this either. tensorflow/lite/tools/make/gen/lib/rpi_armv6/libtensorflow-lite.a

Here is my setup:

  • Raspbian GNU/Linux 10 (buster)
  • Raspberry Pi Zero
  • Compile natively on Raspberry Pi using this guide
  • Trying to install Tensorflow lite as a standalone
  • Python version: 3.7.3
2 Answers

This error means that Tensorflow Lite has not been installed.

To install it, follow the instructions on the official site:

If you're running Debian Linux or a derivative of Debian (including Raspberry Pi OS), you should install from our Debian package repo. This requires that you add a new repo list and key to your system and then install as follows:
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install python3-tflite-runtime

For all other systems, you can install with pip:

pip3 install --extra-index-url https://google-coral.github.io/py-repo/ tflite_runtime

If you'd like to manually install a Python wheel, you can select one from all tflite_runtime wheels.

Tensorflow lite framework has been developed for embedded devices based on Linux. Eg. Coral by Google, Raspberry Pi and others.

In order to get rid of this error, we can install the tflite framework based on the device. For Linux based ARM x64 boards having python3.6, please use

pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp36-cp36m-linux_aarch64.whl

For more information, please check out the link here

Related