前言
公司在做一个金融量化项目,老大突然叫到我说,为了用户使用方便,要我在FAQ中将TA-lib的所有技术指标都写一个小例子。由于之前并没有装过TA-lib,于是就发生了下面的故事
关于TA-lib安装
折腾了一个好半天才把TA-lib安装上,主要一开始就去官网下载,但是好多依赖官网并没有说清楚,由于以前也没装过,所以安装过程中还遇到了一些报错。
下载TA-lib的gcc依赖
Linux依赖下载地址:ta-lib-0.4.0-src.tar.gz ,其他平台的依赖在官网可以找到。
地址:http://ta-lib.org/hdr_dw.html
解压文件并安装依赖
$ untar and cd
$ ./configure --prefix=/usr
$ make
$ sudo make install
安装TA-lib的python包
pip install TA-lib
安装过程中的报错
报错1:
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
error: command 'gcc' failed with exit status 1
解决办法:
sudo dnf install redhat-rpm-config
报错2:
talib/_ta_lib.c:4:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
解决办法:
sudo dnf install python-devel # 如果不行就用下面两行
sudo dnf install python2-devel
sudo dnf install python3-devel
报错3:
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
解决办法(root执行):
yum install gcc-c++
其它平台
其它平台大概的安装步骤在GitHub上面给的很详细,甚至常见的安装过程中的报错都列了出来。附地址:[TA-lib on GitHub]