CentOS 7.6 安装python talib(含Windows 10 下安装)

环境信息:

ta-lib c++库版本:0.4
ta-lib 版本:0.4.17
python 版本:3.6.6
操作系统 版本:centos 7.6

安装介质清单:
1)TA-Lib-0.4.10文件夹
talib的python安装包
2)ta-lib-0.4.0-src.tar.gz
talib的c++库

第一步:下载安装介质:

TA-Lib-0.4.10 ——到pypi上搜talib
ta-lib-0.4.0-src.tar.gz——百度talib,进入官网,左侧菜单Download,在右侧表格中选ta-lib-0.4.0-src

第二步:解压压缩包

wget https://sourceforge.net/projects/ta-lib/files/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz/download
mv download ta-lib-0.4.0-src.tar.gz
# wget https://phoenixnap.dl.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz

第三步:安装c++库

cd ta-lib
./configure --prefix=/usr
make
make install

第四步:查找 libta_lib.so.0文件路径

cd /usr
find -name libta_lib.so.0
./usr /lib/libta_lib.so.0

第五步:添加 /usr /lib 路径到环境变量中

在 /etc/profile 文件内添加下列行

echo "export LD_LIBRARY_PATH=/usr/lib" >> /etc/profile

第六步:激活环境变量

source /etc/profile

第七步:加载库

默认的ta_lib的c程序库被包含到/usr/lib里面了,系统可能不能找到

echo "/usr/lib/" >> /etc/ld.so.conf
ldconfig

如果不配置可能报错:

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3/lib/python3.6/site-packages/talib/__init__.py", line 4, in <module>
    from . import common
ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory

第八步:安装python talib包

pip install ta-lib -U

Collecting ta-lib
Using cached https://files.pythonhosted.org/packages/90/05/d4c6a778d7a7de0be366bc4a850b4ffaeac2abad927f95fa8ba6f355a082/TA-Lib-0.4.17.tar.gz
Requirement already satisfied, skipping upgrade: numpy in /opt/py3/lib/python3.6/site-packages (from ta-lib) (1.16.0)
Installing collected packages: ta-lib
Running setup.py install for ta-lib ... done
Successfully installed ta-lib-0.4.17

第九步:验证安装

python
>>>import talib
>>>

10、附:Windows 10 下安装

下面步骤1和2,二选一。

1. 下载安装 Microsoft Visual C++ 14.0.exe

网盘链接:https://pan.baidu.com/s/126nvvFoO2-q7j2CykgMoeg 提取码:a8un

2. 微软官网下载安装 Microsoft Visual C++ 14.2 Build Tools

官方链接:https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16

3. 下载 ta-lib-0.4.0-msvc.zip

http://ta-lib.org/hdr_dw.html
链接:https://pan.baidu.com/s/1uv9-a__Pp-8gWOzAv1mXww
提取码:v7cz
解压到 c:\ 下

4. 下载安装 TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl

https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
下载地址(Python 3.6):https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl
下载地址(Python 3.7):https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/TA_Lib-0.4.17-cp37-cp37m-win_amd64.whl

5. 验证TA-Lib

6. 安装tushare
pip install ipython
pip install numpy
pip install pandas
pip install requests
pip install bs4
pip install tushare

7. 安装 baostock
pip install baostock

点赞
  1. 爱壮壮的小帅说道:
    Firefox Windows 10
    对于图片,我们都是同道中人。哈哈 :tushe:
    1. admin说道:
      Google Chrome Windows 10
      可以常联系

发表评论

电子邮件地址不会被公开。必填项已用 * 标注