pythongoogle-colaboratoryta-lib

Install Ta-Lib Library in Google Colab Current Latest: 3.11.11 in Jan-2025


As 3.11.11 Python version rolled out in Jan-2025 in Google Colab Runtime, Ta-Lib Library stopped working.

Earlier I used to install Ta-Lib as below in Colab:

url = 'https://anaconda.org/conda-forge/libta-lib/0.4.0/download/linux-64/libta-lib-0.4.0-h166bdaf_1.tar.bz2'
!curl -L $url | tar xj -C /usr/lib/x86_64-linux-gnu/ lib --strip-components=1
url = 'https://anaconda.org/conda-forge/ta-lib/0.4.19/download/linux-64/ta-lib-0.4.19-py310hde88566_4.tar.bz2'
!curl -L $url | tar xj -C /usr/local/lib/python3.10/dist-packages/ lib/python3.10/site-packages/talib --strip-components=3
import talib

Current Error:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4087    0  4087    0     0   7283      0 --:--:-- --:--:-- --:--:--  7298
100  517k  100  517k    0     0   367k      0  0:00:01  0:00:01 --:--:-- 1038k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4159    0  4159    0     0  10406      0 --:--:-- --:--:-- --:--:-- 10397
100  392k  100  392k    0     0   330k      0  0:00:01  0:00:01 --:--:-- 3510k
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-0c7c4394e52f> in <cell line: 0>()
      3 url = 'https://anaconda.org/conda-forge/ta-lib/0.4.19/download/linux-64/ta-lib-0.4.19-py310hde88566_4.tar.bz2'
      4 get_ipython().system('curl -L $url | tar xj -C /usr/local/lib/python3.10/dist-packages/ lib/python3.10/site-packages/talib --strip-components=3')
----> 5 import talib

ModuleNotFoundError: No module named 'talib'

For 3.11.11 Colab Version, how to install Ta-lib Library

!python3 --version
Python 3.11.11

Earlier Post referred: How to install TA-Lib in Google Colab?


Solution

  • I have updated the answer in the original question. I copy it here just in case.

    url = 'https://anaconda.org/conda-forge/libta-lib/0.4.0/download/linux-64/libta-lib-0.4.0-h166bdaf_1.tar.bz2'
    !curl -L $url | tar xj -C /usr/lib/x86_64-linux-gnu/ lib --strip-components=1
    !pip install conda-package-handling
    !wget https://anaconda.org/conda-forge/ta-lib/0.5.1/download/linux-64/ta-lib-0.5.1-py311h9ecbd09_0.conda
    !cph x ta-lib-0.5.1-py311h9ecbd09_0.conda
    !mv ./ta-lib-0.5.1-py311h9ecbd09_0/lib/python3.11/site-packages/talib /usr/local/lib/python3.11/dist-packages/
    import talib