Install CaboCha in a non-Anaconda environment (Win)

Dedicate this article to all non-Anaconda environment Python users.

This is Ogadora. As the title says. I spent more than a day on this, so it was a memorial service. It's basically the same as the Anaconda environment, but it seems to throw an error because the required modules are not installed. I have already installed Python, so I don't want to install Anaconda> <I recommend it to people. But it's a hassle, so unless it's too bad, let's install Anaconda. My environment is Windows 10.

Prerequisites

It seems that Python will not work unless it is a 32-bit version. Please download from here. I downloaded and installed the Windows x86 web-based installer.

PS C:\WINDOWS\system32> py -3.8-32 -V
Python 3.8.3

If it is displayed like this, it is OK. When coexisting with the 64-bit version, the 64-bit version will be called unless the -3.8-32 (3.8 changes depending on the version) option is specified.

PS C:\WINDOWS\system32> py
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
PS C:\WINDOWS\system32> py -3.8-32
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

You can check it like this. Also, to explicitly call the 32-bit version with pip

py -3.8-32 -m pip install hogehoge Please keep in mind. By the way, let's upgrade pip.

py -3.8-32 -m pip install --upgrade pip

Various installations (reference article)

next CaboCha & Python3 environment construction (Windows version) Please make various preparations by referring to. To summarize the procedure briefly

  1. Install MeCab
  2. Install CaboCha
  3. Installation of Visual C ++ compilation environment is not it. This part is the same for Anaconda and others. Please install both UTF-8 versions.

Install numpy + mkl

This is different from Anaconda. It's a Numpy module, but it can't be used if it's installed with pip. It seems that it is included as standard in Anaconda, but it will be a little troublesome in a non-Anaconda environment. By the way, if you try to use CaboCha as it is

Traceback (most recent call last):
  File "A:/codes/python/test.py", line 4, in <module>
    import CaboCha
  File "C:\Users\ogadra\AppData\Local\Programs\Python\Python38-32\lib\site-packages\CaboCha.py", line 28, in <module>
    _CaboCha = swig_import_helper()
  File "C:\Users\ogadra\AppData\Local\Programs\Python\Python38-32\lib\site-packages\CaboCha.py", line 24, in swig_import_helper
    _mod = imp.load_module('_CaboCha', fp, pathname, description)
  File "C:\Users\ogadra\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\ogadra\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 344, in load_dynamic
    return _load(spec)
ImportError: DLL load failed while importing _CaboCha:The specified module cannot be found.

Process finished with exit code 1

I get an error like this. I struggled to say, "Which is the specified module? !!!"

First of all, if you already have numpy, uninstall it.

py -3.8-32 -m pip uninstall numpy

Then install Wheel. Wheel is like a library needed to load a python module from a whl file.

py -3.8-32 -m pip install wheel

Next, check the version that can be installed with wheel. If you want to use PowerShell as it is, please do as follows.

PS C:\WINDOWS\system32> py -3.8-32
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wheel.pep425tags
>>> print(wheel.pep425tags.get_supported(-1))
C:\Users\ogadra\AppData\Local\Programs\Python\Python38-32\lib\site-packages\wheel\pep425tags.py:80: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
  if get_flag('Py_DEBUG',
[('cp38', 'cp38', 'win32'), ('cp38', 'none', 'win32'), ('cp38', 'none', 'any'), ('cp3', 'none', 'any'), ('cp37', 'none', 'any'), ('cp36', 'none', 'any'), ('cp35', 'none', 'any'), ('cp34', 'none', 'any'), ('cp33', 'none', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', 'any'), ('py3', 'none', 'win32'), ('py38', 'none', 'any'), ('py3', 'none', 'any'), ('py37', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
>>>

A list will be returned. How to read this list ('cp38', 'cp38', 'win32') When there is a notation hogehoge-cp38-cp38-win32.whl It corresponds to the installation of the file, it is OK if you catch it. I think that Python 3.8.X environment supports cp38. The whl file can be installed from here. There are various things, but I will download it using Ctrl + F etc. In my environment, I downloaded the following files. (Maybe there are some that you don't need)

・ Numpy-1.19.0 + mkl-cp38-cp38-win32.whl ・ Scipy-1.5.1-cp38-cp38-win32.whl ・ Scikit_learn-0.23.1-cp38-cp38-win32.whl ・ Pandas-1.0.5-cp38-cp38-win32.whl ・ Matplotlib-3.3.0rc1-cp38-cp38-win32.whl

To install from the whl file, cd to the directory where you saved the whl file and cd

py -3.8-32 -m pip install [file name]

You can do it. To check if numpy with mkl is installed

import numpy as np
np.show_config()

Then various things will come out. blas_mkl_info: If the item of is not ** NOT AVAILABLE **, the installation is completed normally. See Scipy in the same way.

Verification

You should now have CaboCha installed in a non-Anaconda environment. For confirmation, I think it is good to run the code of Reference site. (Because it supports Python3.) If it doesn't work, try the following. -Reinstall Cabocha, MeCab (check again if it is installed with UTF-8) ・ Try installing cabocha from whl The latter can be downloaded from here.

Thank you for your hard work. Have a good Japanese analysis life!

Recommended Posts

Install CaboCha in a non-Anaconda environment (Win)
Install Django in a pipenv virtual environment
Pip install in proxy environment
Install CaboCha in Ubuntu environment and call it with Python.
Install scrapy in python anaconda environment
install tensorflow in anaconda + python3.5 environment
Install rJava on Linux in R3.6 environment.
Creating a virtual environment in an Anaconda environment
I started Node.js in a virtual environment
[mac] Install R in pyenv + Jupyter-Lab environment
Install the package in an offline environment
Use WebDAV in a Portable Docker environment
How to install python package in local environment as a general user
Build a LAMP environment in a very short time
Create a Vim + Python test environment in 1 minute
System switching occurs in a CentOS 7 cluster environment
Ubuntu18.04.05 Creating a python virtual environment in LTS
Use the latest pip in a virtualenv environment
Install python package in personal environment on Ubuntu
Create a virtual environment with conda in Python
Build a Django environment with Vagrant in 5 minutes
Install the python package in an offline environment
Install Python 3.5.1 + numpy + scipy + α in Windows environment
Install gensim in conda environment (and also install mecab)
Use Python in your environment from Win Automation
Set a fixed IP in the Linux environment
Think about building a Python 3 environment in a Mac environment
Work in a virtual environment with Python virtualenv.
Build a Minecraft plugin development environment in Eclipse
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Install LightGBM in an OS X virtualenv environment
Use a free GPU in your favorite environment
Procedure to install TensorFlow in fish shell environment (Anaconda 4.0.0)
[For beginners] Install the package in the Anaconda environment (Janome)
Use Sudachipy's learned word2vec in a low memory environment
Until you install TensorFlow-GPU with pip in Windows environment
Setting up Jupyter Lab in a Python 3.9 venv environment
How to install poetry (error handling) in zsh environment
Build a Django environment for Win10 (with virtual space)
install diagrams in wsl
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
dict in dict Makes a dict a dict
virtualenvwrapper in windows environment
virtual environment in python
Create a Python environment
Development environment in Python
Python environment construction @ Win7
Try running python in a Django environment created with pipenv
Install LAMP on Amazon Linux 2 and build a WordPress environment.
I tried the super-resolution algorithm "PULSE" in a Windows environment
Build Azure Pipelies with Azure DevOps in a Linux self-hosted environment
[Django3] Display a web page in Django3 + WSL + Python virtual environment
Build a Python development environment in Eclipse (add HTML editor)
A story that stumbled when using pip in a proxy environment
Building a development environment for Android apps-creating Android apps in Python
Resolve a Segmentation fault that occurs in Ubuntu 16.04+ Tensorflow environment
A note on how to load a virtual environment in PyCharm
Install Jupiter Notebook on Windows with pip in proxy environment
How to develop in a virtual environment of Python [Memo]