TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.56k stars 1.75k forks source link

Instalation error Win11 system #639

Closed cristeam29 closed 7 months ago

cristeam29 commented 8 months ago

I'm struggling to install ta-lib on my win11 machine. What should've been just a pip install ta-lib and 20 sec later all done, transformed into an endless sequence of errors. I managed to progess with some of them, but now I am stuck with this one and no idea how to move forward. I'm running Python 3.10. I've done the steps below: Installed Visual Studio Community 2022 Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib Run "x64 Native Tools Command Prompt" cd C:\ta-lib\c\make\cdr\win32\msvc nmake Went back to Pycharm, hit again "pip install ta-lib" and I get the error below:

"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\
ta-lib\c\lib /LIBPATH:C:\Users\cris\AppData\Local\Programs\Python\Python310\libs /LIBPATH:C:\Users\cris\AppData\Local\Programs\Python\Python310 /LIBPATH:C:\Users\cris\AppData\Local\Programs\Python\Python310
\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x64" "/LIBPA
TH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x64" ta_libc_cdr.lib /EXPORT:PyInit__ta_lib build\temp.win-amd64-cpython-310\Release\talib/_ta_lib.obj /OUT:build\lib.win-amd64-cpython-310\talib\_ta_lib.cp310-win_amd64.pyd /IMPLIB:build\temp.win-amd64-cpython-310\Release\talib\_ta_lib.cp310-win_amd64.lib
         Creating library build\temp.win-amd64-cpython-310\Release\talib\_ta_lib.cp310-win_amd64.lib and object build\temp.win-amd64-cpython-310\Release\talib\_ta_lib.cp310-win_amd64.exp
      _ta_lib.obj : error LNK2001: unresolved external symbol TA_CDLBREAKAWAY_Lookback
      _ta_lib.obj : error LNK2001: unresolved external symbol TA_CDLEVENINGSTAR
.......................... (many similar rows so I deleted all to make error easier to read)
      _ta_lib.obj : error LNK2001: unresolved external symbol TA_BBANDS
      _ta_lib.obj : error LNK2001: unresolved external symbol TA_CDLRISEFALL3METHODS_Lookback
      _ta_lib.obj : error LNK2001: unresolved external symbol TA_GetVersionString
      build\lib.win-amd64-cpython-310\talib\_ta_lib.cp310-win_amd64.pyd : fatal error LNK1120: 339 unresolved externals
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for TA-Lib
Failed to build TA-Lib
ERROR: Could not build wheels for TA-Lib, which is required to install pyproject.toml-based projects

Does anyone know how to fix this to move forward?

mrjbq7 commented 8 months ago

I just tried this on a fresh windows 11 computer:

1) Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib. 2) Run x64 Native Tools Command Prompt 3) cd c:\ta-lib\c\make\cdr\win32\msvc 4) nmake 5) python3 -m pip install ta-lib 6) python3 -c "import talib; print(talib.__version__)"

Work's fine. I'm not sure what's going on with your Pycharm, but those errors imply that it can't find the library ta_libc_cdr.lib in C:\ta-lib\c\lib\, so perhaps check that file exists and was compiled properly (maybe dumpbin /symbols or dumpbin /exports)

cristeam29 commented 8 months ago

Well, the ta_libc_cdr.lib file was there. But I suspected there might have been something wrong with the compilation. Since I didn't know how to check if this was successfull, I deleted the whole ta-lib folder from C drive and unzip it again and re-run nmake. And..... good news, it produced a different result, the sequence of compiled files was much larger. Went back to Pycharm pip install ta-lib and finally instalation is completed. So I guess your post did enough to convince me to start over again and finally make it. Thank you!

mrjbq7 commented 7 months ago

I'm glad it worked for you. I'm not sure what happened, perhaps you ran the x86 Native Tools Command Prompt which builds 32-bit libraries.

In any event, it would be nicer to bundle the TA-Lib C library into wheels for binary installation, I should work on that sometime soon.