X

於 Linux 使用 Python PIP3 安裝 TA-Lib

Python3 的 TA-Lib 有很多技術分析的函數(Function) 已經寫好,可以直接套用。

不過 TA-Lib 於 Debian Linux 要直接 pip3 install 會遇到點困難~

於 Linux 使用 Python PIP3 安裝 TA-Lib

官網:TA-Lib : Technical Analysis Library - Home

使用 pip3 install TA-lib 會遇到下述問題:

  • pip3 install TA-lib
    • x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=.  -fstack-protector-strong -Wform at -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/tmp/pip- build-env-n6c_g8d2/normal/lib/python3.9/site-packages/numpy/core/include -I/usr/include/python3.9 -c talib/talib.c -o build/temp.linux-x86_64-cpython-39/talib/talib.o                                                                    talib/talib.c:747:10: fatal error: ta-lib/ta_defs.h: 沒有此一檔案或目錄                                                                                       747 | #include "ta-lib/ta_defs.h"
          |          ^~~~~~
        compilation terminated.
        error: command '/usr/bin/x86_64-linux-gnu-gcc' failed
        with exit code 1
        ----------------------------------------
        ERROR: Failed building wheel for Ta-Lib
      Failed to build Ta-Lib
      ERROR: Could not build wheels for Ta-Lib which use PEP 517 and cannot be installed directly

於 Debian Linux 使用 PIP3 安裝 TA-Lib 步驟

  1. 先到官網的下載頁面:TA-Lib Technical Analysis Library - Download,下載 ta-lib-0.4.0-src.tar.gz
  2. wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz # 這個就是從官網下載的連結
  3. tar -xzf ta-lib-0.4.0-src.tar.gz
  4. cd ta-lib/
  5. ./configure --prefix=/usr
  6. make
  7. sudo make install # 會安裝 Library 到這些地方
    • ls /usr/lib/libta_lib.
      • /usr/lib/libta_lib.a # 主要用這個
      • /usr/lib/libta_lib.la
      • /usr/lib/libta_lib.so
      • /usr/lib/libta_lib.so.0
      • /usr/lib/libta_lib.so.0.0.0
  8. pip3 install TA-lib # 再來就可以使用 pip 安裝 TA-lib,就可以正常完成了~
    • Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from TA-lib)
    • Stored in directory: /home/user/.cache/pip/wheels/08/d3/5c/8866d2115d6b73b448af7f8e361bf267a1d82b87e318bxxxxx
    • Successfully built TA-lib
    • Installing collected packages: TA-lib

相關網頁

Tsung: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post