Windows10 64位下 python安装Ta-Lib

Last modified date

Windows10 64位下 python安装Ta-Lib

在Windows上使用Python 安装ta-lib出现了链接程序报错。

C:\Users\Secr>pip install ta-lib
Collecting ta-lib
  Using cached TA-Lib-0.4.10.tar.gz
Building wheels for collected packages: ta-lib
  Running setup.py bdist_wheel for ta-lib ... error
  Complete output from command c:\users\Secr\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Secr\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\ta-lib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Secr\AppData\Local\Temp\tmpqstzmsgspip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\talib
  copying talib\deprecated.py -> build\lib.win-amd64-3.5\talib
  copying talib\test_abstract.py -> build\lib.win-amd64-3.5\talib
  copying talib\test_data.py -> build\lib.win-amd64-3.5\talib
  copying talib\test_func.py -> build\lib.win-amd64-3.5\talib
  copying talib\test_stream.py -> build\lib.win-amd64-3.5\talib
  copying talib\__init__.py -> build\lib.win-amd64-3.5\talib
  running build_ext
  skipping 'talib\common.c' Cython extension (up-to-date)
  building 'talib.common' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\talib
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\Secr\anaconda3\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\users\Secr\anaconda3\include -Ic:\users\Secr\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctalib\common.c /Fobuild\temp.win-amd64-3.5\Release\talib\common.obj
  common.c
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\ta-lib\c\lib /LIBPATH:c:\users\Secr\anaconda3\libs /LIBPATH:c:\users\Secr\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" ta_libc_cdr.lib /EXPORT:PyInit_common build\temp.win-amd64-3.5\Release\talib\common.obj /OUT:build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib
  common.obj : warning LNK4197: export 'PyInit_common' specified multiple times; using first specification
     Creating library build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib and object build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.exp
  common.obj : error LNK2001: unresolved external symbol TA_SetUnstablePeriod
  common.obj : error LNK2001: unresolved external symbol TA_Shutdown
  common.obj : error LNK2001: unresolved external symbol TA_Initialize
  common.obj : error LNK2001: unresolved external symbol TA_GetUnstablePeriod
  common.obj : error LNK2001: unresolved external symbol TA_GetVersionString
  build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd : fatal error LNK1120: 5 unresolved externals
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120

  ----------------------------------------
  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
    Complete output from command c:\users\Secr\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Secr\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\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\Secr\AppData\Local\Temp\pip-qxmjmn5m-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\talib
    copying talib\deprecated.py -> build\lib.win-amd64-3.5\talib
    copying talib\test_abstract.py -> build\lib.win-amd64-3.5\talib
    copying talib\test_data.py -> build\lib.win-amd64-3.5\talib
    copying talib\test_func.py -> build\lib.win-amd64-3.5\talib
    copying talib\test_stream.py -> build\lib.win-amd64-3.5\talib
    copying talib\__init__.py -> build\lib.win-amd64-3.5\talib
    running build_ext
    skipping 'talib\common.c' Cython extension (up-to-date)
    building 'talib.common' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\talib
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\Secr\anaconda3\lib\site-packages\numpy\core\include -Ic:\ta-lib\c\include -Ic:\users\Secr\anaconda3\include -Ic:\users\Secr\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctalib\common.c /Fobuild\temp.win-amd64-3.5\Release\talib\common.obj
    common.c
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\ta-lib\c\lib /LIBPATH:c:\users\Secr\anaconda3\libs /LIBPATH:c:\users\Secr\anaconda3\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" ta_libc_cdr.lib /EXPORT:PyInit_common build\temp.win-amd64-3.5\Release\talib\common.obj /OUT:build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib
    common.obj : warning LNK4197: export 'PyInit_common' specified multiple times; using first specification
       Creating library build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.lib and object build\temp.win-amd64-3.5\Release\talib\common.cp35-win_amd64.exp
    common.obj : error LNK2001: unresolved external symbol TA_SetUnstablePeriod
    common.obj : error LNK2001: unresolved external symbol TA_Shutdown
    common.obj : error LNK2001: unresolved external symbol TA_Initialize
    common.obj : error LNK2001: unresolved external symbol TA_GetUnstablePeriod
    common.obj : error LNK2001: unresolved external symbol TA_GetVersionString
    build\lib.win-amd64-3.5\talib\common.cp35-win_amd64.pyd : fatal error LNK1120: 5 unresolved externals
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120

    ----------------------------------------
Command "c:\users\Secr\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Secr\\AppData\\Local\\Temp\\pip-build-vv02ktg_\\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\Secr\AppData\Local\Temp\pip-qxmjmn5m-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Secr\AppData\Local\Temp\pip-build-vv02ktg_\ta-lib\

需要用到TA-Lib这个库,因为系统版本已经Win 10了,就直接从官网上下载的,但是解压后安装还是会报错。

仔细看了下错误,发现实际上要使用的是64位的版本,官方直接提供的是32位的版本。

那么需要我们自己重新编译生成64位的库。

运行 VS2019 x64 Native Tools Command Prompt , 切换到ta-lib的目录中。

在目录 ta-lib\c\make\cdr\win32\msvc 中 运行nmake。

等上面的编译完成后,重新使用pip安装 ta-lib 就可以了。

淋雨