kuroの覚え書き

96の個人的覚え書き

somocluで自己組織マッピング

Self Organized Mappingをpythonでやりたくてsomocluをインストールしてみた。

まずはMacに入れてみると、

Python 3.9.6 (default, Jun 29 2021, 06:20:32) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import somoclu
Warning: the binary library cannot be imported. You cannot train maps, but you can load and analyze ones that you have already saved.
If you installed Somoclu with pip on macOS, this typically means missing a linked library. If you compiled Somoclu with GCC, please make sure you have set DYLD_LIBRARY_PATH to include the GCC path. For more information, please refer to the documentation.
>>>

とつれなくエラー。
なんか面倒くさそうだし、どうせサーバにアプリを仕込みたいのでCentOS7にインストールしてみる。

Python 3.9.10 (main, Jan 13 2022, 23:32:03) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import somoclu
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/numpy/core/overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/somoclu/__init__.py", line 11, in <module>
    from .train import Somoclu
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/somoclu/train.py", line 12, in <module>
    import matplotlib.cm as cm
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/matplotlib/__init__.py", line 107, in <module>
    from . import _api, cbook, docstring, rcsetup
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 28, in <module>
    import numpy as np
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/numpy/__init__.py", line 144, in <module>
    from . import core
  File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.10/lib/python3.9/site-packages/numpy/core/__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/home/linuxbrew/.linuxbrew/opt/python@3.9/bin/python3.9"
  * The NumPy version is: "1.22.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libopenblas.so.0: cannot open shared object file: No such file or directory

>>>

もっとエラーが出た。おいっ!お前もか。
仕方がない。
libopenblas.so.0
がないよって言っているので素直に入れてやる。

$ brew install openblas

コレで使えるようになったらしい。