How to pip install TA-Lib on Python 3.12 on Windows 11?

1k views Asked by At

How to pip install TA-Lib on Python 3.12 on Windows 11 ? Please give me comand for cmd or VS code terminal .

I tried:

pip install Ta-Lib

Defaulting to user installation because normal site-packages is not writeable
Collecting Ta-Lib
  Using cached TA-Lib-0.4.28.tar.gz (357 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in c:\users\alan\appdata\roaming\python\python312\site-packages (from Ta-Lib) (1.26.3)
Building wheels for collected packages: Ta-Lib
  Building wheel for Ta-Lib (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for Ta-Lib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      <string>:77: UserWarning: Cannot find ta-lib library, installation may fail.
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\talib
      copying talib\abstract.py -> build\lib.win-amd64-cpython-312\talib
      copying talib\deprecated.py -> build\lib.win-amd64-cpython-312\talib
      copying talib\stream.py -> build\lib.win-amd64-cpython-312\talib
      copying talib\__init__.py -> build\lib.win-amd64-cpython-312\talib
      running build_ext
      building 'talib._ta_lib' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [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
1

There are 1 answers

0
Talha Tayyab On

Get the latest zipfile for Python 3.12 from here:

https://github.com/TA-Lib/ta-lib-python/issues/127#issuecomment-1793716236

Extract zipfile to C:\, like this C:\ta-lib

Download and install Visual C++ build tools from:

https://visualstudio.microsoft.com/visual-cpp-build-tools/

Finally install:

pip install ta-lib