[PYTHON] A memorandum until using mecab on a machine that cannot use sudo

He is a troubled uncle who is added to the Advent calendar and never writes without knowing it. .. ..

I'm working in a corporate server environment for joint research. I didn't get sudo privileges ... I want to use mecab, but I'm sorry I didn't install it. Basically, I just specify the user directory for --prefix ... It's just a memorandum

Premise

Put compressed files of python2. *. *, Mecab, ipadic, mecab-python in ~ / temp (directory name can be anything)

python installation

tar xvf Python-2.*.*.tgz
cd Python2.*.*
./configure --prefix=/home/user-name/usr/local
make
make install

install mecab

tar xvf mecab-0.996.tar.gz
cd mecab-0.996
./configure --prefix=$HOME/usr/local --with-charset=utf8 --enable-utf8-only
make
make install

.*shrc


export PATH=/home/user-name/usr/local/bin:$PATH

Dictionaries installation

tar xvzf mecab-ipadic-2.7.0-********.tar.gz
cd mecab-ipadic-2.7.0-*********
./configure --with-charset=utf8 --with-dicdir=~/local/mecab-dic/ipadic-utf8
make
make install

Change / home / user-name / usr / local / etc / mecabrc

mecabrc


.
.
dicdir = /home/user-name/local/mecab-dic/ipadic-utf8
.
.

install mecab-python

tar xvzf mecab-python-0.996.tar.gz
cd mecab-python-0.996
vim setup.py(The edited contents are as ↓)
python setup.py build
python setup.py install

Rewrite all directory paths described in setup.py

setup.py


#!/usr/bin/env python

from distutils.core import setup,Extension,os
import string

def cmd1(str):
    return os.popen(str).readlines()[0][:-1]

def cmd2(str):
    return string.split (cmd1(str))

setup(name = "mecab-python",
        version = cmd1("/home/user-name/temp/mecab-0.996/mecab-config --version"),
        py_modules=["MeCab"],
        ext_modules = [
                Extension("_MeCab",
                        ["MeCab_wrap.cxx",],
                        include_dirs=cmd2("/home/user-name/temp/mecab-0.996/mecab-config --inc-dir"),
                        library_dirs=cmd2("/home/user-name/temp/mecab-0.996/mecab-config --libs-only-L"),
                        libraries=cmd2("/home/user-name/temp/mecab-0.996/mecab-config --libs-only-l"))
                        ])

Finally pass the pass

.*shrc


.
.
export PATH=/home/user-name/usr/local/lib:$PATH
export LD_LIBRARY_PATH=/home/user-name/usr/local/lib
.
.

reference: http://qiita.com/saicologic/items/ab70e14f7e2ec2ee0b4d http://oshiete.goo.ne.jp/qa/8883975.html

Recommended Posts

A memorandum until using mecab on a machine that cannot use sudo
A memorandum because I stumbled on trying to use MeCab in Python
[Complete memorandum] A collection of codes that I often use but cannot remember
A memorandum on how to use keras.preprocessing.image in Keras
A memorandum that you will often use in Python's Selenium
Until building a Python development environment using pyenv on Ubuntu 20.04
When using property, use a class that inherits object (new-style class)
A memorandum of using eigen3
Dual_boot windows10 and linux by using clover on a uefi PC that cannot be booted from nvme
A memorandum when using beautiful soup
Notes on using MeCab from Python
Using a serial console on Ubuntu 20.04
Estimate the probability that a coin will appear on the table using MCMC