win10 64位系统 talib 安装失败问题处理
背景
人生苦短,我用python. 虽然大数据入门是 java, 但我入门就换 python 语言。而在最近数据分析过程遇到一个问题,于是把处理过程记录一下
程序执行过程中,遇到 模块 talib 缺失的问题:
D:\Dev\env\measure\Scripts\python.exe D:/Dev/workplace/python/data-analyze/data/load_hive_data.py
Traceback (most recent call last):
File "D:/Dev/workplace/python/data-analyze/data/load_hive_data.py", line 1, in <module>
from intodatabase.util.load_data_util import LoadDataUtil
File "D:/Dev/workplace/python/data-analyze/data/load_hive_data.py", line 7, in <module>
import talib as ta
ModuleNotFoundError: No module named 'talib'
很常见,没有就 pip 加载嘛。于是乎 pip install talib
, 手指轻轻打下命令,回传确认执行。结果意外幕出现了
pip install -i https://pypi.douban.com/simple/ talib
Looking in indexes: https://pypi.douban.com/simple/
Collecting talib
Downloading https://pypi.doubanio.com/packages/1a/80/3492aa3065d7d81a6c51db78920108f84fbe19c4e2740f6bbb83d42f77a4/talib-0.1.1.tar.gz (1.3 kB)
Using legacy 'setup.py install' for talib, since package 'wheel' is not installed.
Installing collected packages: talib
Running setup.py install for talib ... error
ERROR: Command errored out with exit status 1:
command: 'd:\dev\env\measure\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-xchq4_kk\\tali
...
xchq4_kk\talib_3bf20ca4ad49420eb9bdfd123ca06d49\setup.py", line 20, in run
raise Exception("You probably meant to install and run ta-lib")
Exception: You probably meant to install and run ta-lib
----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\dev\env\data-analyze\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize;
single-version-externally-managed --compile --install-headers 'd:\dev\env\measure\include\site\python3.7\talib' Check the logs for full command output.
喵喵喵,什么 pip 安装不成功?怎么回事。于是乎查了下问:
原因在于
python pip
源、[TA-Lib官网]下载的 TA-Lib 安装包其实是32位的,如果你的系统平台是64位的,也无法正确安装。
正确的方法是下载 TA-Lib 64位安装包,本地安装,64位安装包官网并没有提供,我们必须自行下载。
于是我们到 [加州大学的 Python 库]里面找 TA-Lib
-
[TA-Lib]: a wrapper for the [TA-LIB] Technical Analysis Library.
cp27‑cp27m‑win32
代表的是 Python2.7 - win 32位 安装包, 其他以此类推。由于我的系统是 64位 python 3.7 版本,所以我下载 TA_Lib‑0.4.21‑cp37‑cp37m‑win_amd64.whl
$ pip install TA_Lib‑0.4.21‑cp37‑cp37m‑win_amd64.whl
Looking in indexes : https://pypi.tuna.tsinghua.edu. cn/simple
Processing c:\windows\system32\ta_lib-0.4.21‑cp37‑cp37m‑win_amd64.whl
Installing collected packages : TA-Lib
Successfu1ly insta1led TA-Lib-0.4.21
于是 ta-lib 在 64 位系统安装问题完美解决