ダーシャのブログ

ゆるゆる生きてていいじゃない

raspberry pi にTA-Libをインストールする

pip install Ta-Libだけではインストールに失敗する

TA-Libに関しては、そのままpipでインストールをすることが出来ない。 インターネットの多くの記事で紹介されている、OSにインストールする方法を試したのだが、少し詰まった箇所があったため防備録にまとめる。

TA-Libインストール方法

osにインストールする

まず初めにosにTA-Libをインストールするため、ファイルをダウンロードし解凍する。

wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib

その後すぐに$ ./configure --prefix=/usrを実行すると以下のエラーが出てインストールされない。

This script, last modified 2006-07-02, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from

  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
and
  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub

If the version you run (./config.guess) is already up to date, please
send the following data and any information you think might be
pertinent to <config-patches@gnu.org> in order to provide the needed
information to handle your system.

config.guess timestamp = 2006-07-02

ホームページからコピーしてきて、config.guess, config.subを更新してやると上手く行く。

./config.guess
./configure --prefix=/usr
make
sudo make install

pip installする

$ pip install TA-Libを行なうと以下のエラーが出る。

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 "/usr/bin/python3"
      * The NumPy version is: "1.24.2"
    
    and make sure that they are the versions you expect.
    Please carefully study the documentation linked above for further help.
    
    Original error was: libcblas.so.3: cannot open shared object file: No such file or directory
    
    ----------------------------------------

libcblas.so.3に関するパッケージをインストールすれば良い

sudo apt-get install libatlas-base-dev
pip install TA-Lib

参考

qiita.com

rikoubou.hatenablog.com