[PYTHON] I stumbled upon installing sentencepiece on ubuntu

table of contents

  1. Environment
  2. Overview
  3. Procedure
  4. Result

1. Environment

2. Overview

I built a python environment on an ec2 instance and tried to put a sentence piece, but I stumbled a little.

~$ pip install sentencepiece
Collecting sentencepiece
  Using cached https://files.pythonhosted.org/packages/72/e0/57edbab017a204e9f39448c1717292437a45b5f7cf3a9dbf4a9c026b03c5/sentencepiece-0.1.94.tar.gz
Installing collected packages: sentencepiece
  Running setup.py install for sentencepiece ... error
    Complete output from command /home/ubuntu/.pyenv/versions/3.7.3/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-p1e9kzi7/sentencepiece/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-cjap2xh6/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/sentencepiece
    copying src/sentencepiece/__init__.py -> build/lib.linux-x86_64-3.7/sentencepiece
    copying src/sentencepiece/sentencepiece_model_pb2.py -> build/lib.linux-x86_64-3.7/sentencepiece
    copying src/sentencepiece/sentencepiece_pb2.py -> build/lib.linux-x86_64-3.7/sentencepiece
    running build_ext
    Package sentencepiece was not found in the pkg-config search path.  #here!
    Perhaps you should add the directory containing `sentencepiece.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'sentencepiece' found
    Cloning into 'sentencepiece'...
    Note: checking out '8336bbd0c1cfba02a879afe625bf1ddaf7cd93c5'.

pkg-configCan't be found.

3. Procedure

3.1 Dependency installation

If you look at github of sentencepiece, you will find the following description.

On Ubuntu, the build tools can be installed with apt-get: % sudo apt-get install cmake build-essential pkg-config libgoogle-perftools-dev

Execute the following command with

sudo apt-get install cmake build-essential pkg-config libgoogle-perftools-dev

3.2 Installation of sentencepiece

pip install sentencepiece

I was able to install it successfully.

Recommended Posts

I stumbled upon installing sentencepiece on ubuntu
Installing pyenv on ubuntu 16.04
I installed tensorRT on Ubuntu 18.04
I installed ROS on Ubuntu 18.04
I stumbled upon trying Pylearn 2
What I stumbled upon using Airflow
I tried Cython on Ubuntu on VirtualBox
I couldn't input Japanese on Ubuntu 20.04
Notes on installing Ubuntu 18.04 on the XPS 15 7590
What I stumbled upon when using CodeIgniter on a Linux server
Notes for installing Sublime Text on Ubuntu
A story that stumbled upon installing matplotlib
I stumbled on the Hatena Keyword API
[Note] Procedures for installing Ubuntu on Windows 10
I installed TensorFlow (GPU version) on Ubuntu
I can't install Dask with pip on Ubuntu
A memo that I stumbled upon when doing a quote RT on Twitter Bot
Shebang on Ubuntu 20.04
What I did when I stumbled on a Django tutorial
I got a UnicodeDecodeError when pip install on ubuntu
I made a Python3 environment on Ubuntu with direnv.
I stumbled upon using MoviePy, so make a note
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
I tried installing the Linux kernel on virtualbox + vagrant
I stumbled upon PyUnicodeUCS4_FromStringAndSize when inserting TensorFlow with pip
Install TensorFlow on Ubuntu
Stumbled when installing PyOCR
When I tried to build a Rails environment on WSL2 (Ubuntu 20.04LTS), I stumbled and fell.
Install PySide2 on Ubuntu
Notes on installing PycURL
Installing Singularity (Ubuntu 18.04 LTS)
Install JModelica on Ubuntu
Installing pandas on python2.6
build Python on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Install Theano on Ubuntu 12.04
Install angr on Ubuntu 18.04
Install pip / pip3 on Ubuntu
An error that stumbled upon learning YOLO on Google Colab
I stumbled on TensorFlow (What is Out of GPU Memory)
Precautions and solutions when installing Ubuntu on NVIDIA GeForce PCs