spm_train command not found

In this troubleshooting guide we learn how to fix spm_train command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

spm_train: command not found

or when using sudo you get the following error message

sudo: spm_train: command not found

Solutions to spm_train: command not found

How To Fix spm_train: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu spm_train is provided by sentencepiece package.

sentencepiece is:

SentencePiece is an unsupervised text tokenizer/detokenizer mainly designed for Neural Network-based text generation systems where the vocabulary size is predetermined prior to the neural model training.

To fix this problem, we can install more using the command below.

sudo apt-get -y install sentencepiece

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install sentencepiece.

sudo apt -y install sentencepiece

Or if you have aptitude installed you can use the following command.

sudo aptitude install sentencepiece

Summary

In this tutorial we learn how to fix spm_train command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.