LoginSignup
4
4

More than 1 year has passed since last update.

ubuntu にsentencepiece をインストール

Last updated at Posted at 2020-11-03

目次

  1. 環境
  2. 概要
  3. 手順
  4. 結果

1. 環境

  • ec2:ubuntu(18.04.5)
  • python:3.7.3

2. 概要

ec2インスタンスに python 環境を構築し、sentencepiece を入れようとしたところ若干つまづいた。

~$ 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.  # ここ!
    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-config が見つからないとのこと。

3. 手順

3.1 依存関係のインストール

sentencepiece の github を見ると以下の記述がある。

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

とのことで以下のコマンドを実行

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

3.2 sentencepiece のインストール

pip install sentencepiece

無事インストールできました。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4