How to install TA-lib in google colab?

2019-08-12 01:37发布

问题:

I'm trying to install TA-Lib package in google colab notebook but without success. I tried this guide and also Installing TA-Lib on python x64

I get this error:

import platform
print (platform.architecture())

import sys
print(sys.version)

!pip install C:/ta-lib/TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl

#########
('64bit', '')
3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0]
 Requirement 'C:/ta-lib/TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl' looks like a 
  filename, but the file does not exist
  TA_Lib-0.4.17-cp36-cp36m-win_amd64.whl is not a supported wheel on this 
  platform.

回答1:

Have you tried following instructions from here?

https://github.com/mrjbq7/ta-lib

And change any sudo apt-get to just !apt. Any cd to %cd

Update: try this

!wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
!tar -xzvf ta-lib-0.4.0-src.tar.gz
%cd ta-lib
!./configure --prefix=/usr
!make
!make install
!pip install Ta-Lib
import talib


回答2:

Another way use the %%bash command . Install either TA-Lib or ta-lib and then `import talib' .

!wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
!tar -xvf ta-lib-0.4.0-src.tar.gz
%%bash
cd ta-lib
./configure --prefix=/usr
make
sudo make install
sudo apt upgrade
#!pip install TA-Lib
!pip install ta-lib

import talib as ta

If you are using Ubuntu and Jupyter then this answer is helpful Unable to install TA-Lib on Ubuntu