今天在进行安装 ta-lib 时报错如下,经过仔细摸索发现解决办法如下:
ERROR: Failed building wheel for ta-lib
Running setup.py clean for ta-lib
Failed to build ta-lib
Installing collected packages: ta-lib
Running setup.py install for ta-lib … error
ERROR: Command errored out with exit status 1:
command: /Users/liangshu/opt/miniconda3/envs/env36/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/7v/myyqxvr17rs5g_117fnsnxv00000gn/T/pip-install-pm2iz_5h/ta-lib_309f9a373ee148b28e4465aa6c54dc6c/setup.py’“'”‘; file=’“'”‘/private/var/folders/7v/myyqxvr17rs5g_117fnsnxv00000gn/T/pip-install-pm2iz_5h/ta-lib_309f9a373ee148b28e4465aa6c54dc6c/setup.py’“'”‘;f = getattr(tokenize, ‘"’“‘open’”’“‘, open)(file) if os.path.exists(file) else io.StringIO(’”‘“‘from setuptools import setup; setup()’”’“‘);code = f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /private/var/folders/7v/myyqxvr17rs5g_117fnsnxv00000gn/T/pip-record-h0xrjyo7/install-record.txt --single-version-externally-managed --compile --install-headers /Users/liangshu/opt/miniconda3/envs/env36/include/python3.6m/ta-lib
cwd: /private/var/folders/7v/myyqxvr17rs5g_117fnsnxv00000gn/T/pip-install-pm2iz_5h/ta-lib_309f9a373ee148b28e4465aa6c54dc6c/
Complete output (28 lines):
/private/var/folders/7v/myyqxvr17rs5g_117fnsnxv00000gn/T/pip-install-pm2iz_5h/ta-lib_309f9a373ee148b28e4465aa6c54dc6c/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
warnings.warn(‘Cannot find ta-lib library, installation may fail.’)
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
creating build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/abstract.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_polars.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_abstract.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/deprecated.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/init.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/stream.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_pandas.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_data.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_func.py -> build/lib.macosx-10.7-x86_64-3.6/talib
copying talib/test_stream.py -> build/lib.macosx-10.7-x86_64-3.6/talib
running build_ext
building ‘talib._ta_lib’ extension
creating build/temp.macosx-10.7-x86_64-3.6
creating build/temp.macosx-10.7-x86_64-3.6/talib
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/liangshu/opt/miniconda3/envs/env36/include -arch x86_64 -I/Users/liangshu/opt/miniconda3/envs/env36/include -arch x86_64 -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/Users/liangshu/opt/miniconda3/envs/env36/lib/python3.6/site-packages/numpy/core/include -I/Users/liangshu/opt/miniconda3/envs/env36/include/python3.6m -c talib/_ta_lib.c -o build/temp.macosx-10.7-x86_64-3.6/talib/_ta_lib.o
解决办法
brew install ta-lib
再次进行
pip install ta-lib
安装成功
Looking in indexes: https://pypi.douban.com/simple
Collecting ta-lib
Using cached https://pypi.doubanio.com/packages/78/f5/59f1d7d0c43d3d96e93249ae9d5415b42591362bfcf2f4e50574ad063312/TA-Lib-0.4.24.tar.gz (269 kB)
Requirement already satisfied: numpy in /Users/liangshu/opt/miniconda3/envs/env36/lib/python3.6/site-packages (from ta-lib) (1.19.5)
Building wheels for collected packages: ta-lib
Building wheel for ta-lib (setup.py) ... done
Created wheel for ta-lib: filename=TA_Lib-0.4.24-cp36-cp36m-macosx_10_7_x86_64.whl size=438311 sha256=87747548b1f54771427dccfb0a817df517f200e950f1900d192ede8853a9c038
Stored in directory: /Users/liangshu/Library/Caches/pip/wheels/4c/8e/85/7cbf746e6a3ac1d11e693060a776016295923a35b0496f2815
Successfully built ta-lib