问题
I am trying to install TA-Lib for Python 3.7. I've already read through a number of solutions, but have come to a point I can't figure out. Here is the message I get from pip:
Collecting ta-lib
Using cached https://files.pythonhosted.org/packages/90/05/d4c6a778d7a7de0be366bc4a850b4ffaeac2abad927f95fa8ba6f355a082/TA-Lib-0.4.17.tar.gz
Requirement already satisfied: numpy in c:\python37_64\lib\site-packages (from ta-lib) (1.15.4)
Installing collected packages: ta-lib
Running setup.py install for ta-lib: started
Command "c:\python37_64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Todd\\AppData\\Local\\Temp\\pip-install-0c2__0gf\\ta-lib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Todd\AppData\Local\Temp\pip-record-3dpfanca\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Todd\AppData\Local\Temp\pip-install-0c2__0gf\ta-lib\
Running setup.py install for ta-lib: finished with status 'error'
Complete output from command c:\python37_64\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Todd\\AppData\\Local\\Temp\\pip-install-0c2__0gf\\ta-lib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Todd\AppData\Local\Temp\pip-record-3dpfanca\install-record.txt --single-version-externally-managed --compile:
C:\Users\Todd\AppData\Local\Temp\pip-install-0c2__0gf\ta-lib\setup.py:79: 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.win-amd64-3.7
creating build\lib.win-amd64-3.7\talib
copying talib\abstract.py -> build\lib.win-amd64-3.7\talib
copying talib\deprecated.py -> build\lib.win-amd64-3.7\talib
copying talib\stream.py -> build\lib.win-amd64-3.7\talib
copying talib\test_abstract.py -> build\lib.win-amd64-3.7\talib
copying talib\test_data.py -> build\lib.win-amd64-3.7\talib
copying talib\test_func.py -> build\lib.win-amd64-3.7\talib
copying talib\test_pandas.py -> build\lib.win-amd64-3.7\talib
copying talib\test_stream.py -> build\lib.win-amd64-3.7\talib
copying talib\__init__.py -> build\lib.win-amd64-3.7\talib
running build_ext
building 'talib._ta_lib' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\talib
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python37_64\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\python37_64\include -Ic:\python37_64\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tctalib/_ta_lib.c /Fobuild\temp.win-amd64-3.7\Release\talib/_ta_lib.obj
_ta_lib.c
talib/_ta_lib.c(524): fatal error C1083: Cannot open include file: 'ta_libc.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
FINISHED
Thanks.
回答1:
Here is what works for me...
Download TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl from here
And use command pip install TA_Lib-0.4.10-cp27-cp27m-win_amd64.whl
I was using Conda4 with python 3.6 64 bit version.
Another way also you can try
To install Ta-Lib with Python 3.6+, Windows 64 bit use this pip install -i https://pypi.anaconda.org/masdeseiscaracteres/simple ta-lib
回答2:
i would suggest installing using the wheel from here. Recently i ran across the same problems while trying to upgrade the library which is again another thing you wouldn't want to do. Hope this helps. Good luck.
回答3:
This is how I fixed this issue in linux: First I downloaded C dependency from: https://ta-lib.org/hdr_dw.html Installed it at a local directory using:
./configure --prefix=<local_path_to_install_c_library>
make
make install
Then used pip
to install ta-lib
pip install --upgrade --global-option=build_ext --global-option="-L<local_path_to_install_c_library>/lib" --global-option="-I<local_path_to_install_c_library>/include" --install-option="--prefix=<local_path_to_install_python_lib>" ta-lib
来源:https://stackoverflow.com/questions/53845708/trouble-installing-ta-lib-in-python-3-7