Put MeCab in "Windows 10; Python3.5 (64bit)"

Due to various circumstances, there was a need to install MeCab in the Windows environment. I managed to do it, but as you can see with a little google, an OS other than Windows is recommended. Since it was solved by combining multiple reference articles + α, keep a work log.

Execution environment

Download and install mecab-0.996.exe

Modification work of mecab-0.996.tar.gz

--Download from http://taku910.github.io/mecab/#download -[Build MeCab for 64-bit Windows (using Visual Studio 2015/2010)](http://www.ipentec.com/document/document.aspx?page=mecab-compile-for-x64-windows- use-x64-windows) as a reference --Go to the src directory

Modification of Makefile.msvc.in

--Copy Makefile.msvc.in ⇒ Rename to Makefile.msvc ――The 5th line

LDFLAGS = /nologo /OPT:REF /OPT:ICF /LTCG /NXCOMPAT /DYNAMICBASE /MACHINE:X64 ADVAPI32.LIB

--Lines 7-8

-DDLL_EXPORT -DHAVE_GETENV -DHAVE_WINDOWS_H -DDIC_VERSION=102 \
-DVERSION="\"0.996\"" -DPACKAGE="\"mecab\"" \

Modification of feature_index.cpp

--Line 356

case 't':  os_ << (unsigned int)path->rnode->char_type; break;

Modification of writer.cpp

--Line 260

case 'L': *os << (unsigned int)lattice->size(); break;

Compile modified ones

--Launch VS2015 Native Tools Command Prompt -Go to the \ mecab-0.996 \ src directory

make.bat

-Overwrite all 〇〇.exe and libmecab.dll in \ mecab-0.996 \ src to C: \ Program Files (x86) \ MeCab \ bin -Overwrite all 〇〇.lib in \ mecab-0.996 \ src to C: \ Program Files (x86) \ MeCab \ sdk --Add C: \ Program Files (x86) \ MeCab \ bin to your PATH

Working on Python modules

Rewrite 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("mecab-config --version"),
	py_modules=["MeCab"],
	ext_modules = [
		Extension("_MeCab",
			["MeCab_wrap.cxx",],
			include_dirs=cmd2("mecab-config --inc-dir"),
			library_dirs=cmd2("mecab-config --libs-only-L"),
			libraries=cmd2("mecab-config --libs-only-l"))
			])

Added to mecab.h

--mecab.h is located in C: \ Program Files (x86) \ MeCab \ sdk

/**
 * Lattice class
 */
class MECAB_DLL_CLASS_EXTERN Lattice {
public:

  virtual void set_result(const char *str)        = 0; //Add this one line

  /**
   * Clear all internal lattice data.
   */
  virtual void clear()              = 0;

compile

--Launch Anaconda Prompt --Go to C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC

vcvarsall.bat

--Move to the mecab-python-0.996 directory at the command prompt

python setup.py build
python setup.py install

Now import MeCab is finally working.

Recommended Posts

Put MeCab in "Windows 10; Python3.5 (64bit)"
Windows10: Install MeCab library in python
3 steps to put Python + mecab in yum only
Create an environment of 64bit Windows + python 2.7 + MeCab 0.996
Python install in 2 lines @Windows
[Python] Show multiple windows in Tkinter
Installing Kivy on Windows10 64bit Python3.5
Hit a command in Python (Windows)
Install python2.7 on windows 32bit environment
Put python, numpy, opencv3 in ubuntu14
Until you put Python in Docker
Installing Kivy-Designer on Windows10 64bit Python3.5
Build mlpy with python3.3 (64bit) (windows 64bit)
Mecab / Cabocha / KNP on Python + Windows
[2021 version] Python installation Windows 10 (64bit) edition
Introduced binding of MeCab (Wakame seaweed) and Python to Windows 7 64bit (2016/08/18)
I put Python 2.7 in Sakura VPS 1GB.
Mouse operation using Windows API in Python
Using venv in Windows + Docker environment [Python]
[Itertools.permutations] How to put permutations in Python
PUT gzip directly to S3 in Python
[Python] [Windows] Serial communication in Python using DLL
[Python] [Windows] Take a screen capture in Python
Python garbled in Windows + Git Bash environment
Quadtree in Python --2
Python in optimization
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Python on Windows
Unittest in python
python windows environment
Epoch in Python
Discord in Python
Python installation (Windows)
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
MeCab from Python
Put MeCab binding for Python with pip on Windows, mac and Linux
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
PYTHON2.7 64bit version
Constant in python
nCr in Python.
format in python
Scons in Python3