1

I need to install the TA-Lib library on python. Where I run the following:

pip install TA-Lib --user

I get this error code:

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-52h2r7l4/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 /tmp/pip-record-meoq431k/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-52h2r7l4/TA-Lib/

I have also tried:

pip3 install TA-Lib 

when I run:

python --version

I get:

Python 2.7.15rc1

Then I run: python3 --version I get:

Python 3.6.7

I can't understand. I have Ubuntu 18.04. Before I have Anaconda, then delete it (hope I delete it correctly) And then install Python 2.7 because I wanted to use Zipline to backtest some strategies, but I cannot use TA-Lib.

Hope someone know the problem, thank you!

cristianc
  • 51
  • 1
  • 2
  • 8
  • Perhaps python tries (I never used ta-lib via python wrappers) to compile ta-lib from sources on fly and failed to find some dependencies. Try `sudo apt-get install build-essential cmake make` before that. – truf Apr 10 '19 at 15:49
  • Thanks for your response, but the problem was not solved. I don't know if it's because I installed and uninstall python 2 times, before installing a third time. I have read a lot of post and can't find the solution. – cristianc Apr 10 '19 at 18:52

2 Answers2

0

I've downloaded TA-Lib-0.4.17.tar.gz that pip3 gets automatically. Opened it - there is no TA-Lib, only wrapper for it. According to its README.md

Dependencies

To use TA-Lib for python, you need to have the TA-Lib already installed. You should probably follow their installation directions for your platform, but some suggestions are included below for reference.

Mac OS X

$ brew install ta-lib

Windows

Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib This is a 32-bit release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library.
Some unofficial (and unsupported) instructions for building on 64-bit Windows 10, here for reference:

  1. Download and Unzip ta-lib-0.4.0-msvc.zip
  2. Move the Unzipped Folder ta-lib to C:\
  3. Download and Install Visual Studio Community 2015
  4. Remember to Select [Visual C++] Feature
  5. Build TA-Lib Library
  6. From Windows Start Menu, Start [VS2015 x64 Native Tools Command Prompt]
  7. Move to C:\ta-lib\c\make\cdr\win32\msvc
  8. Build the Library nmake

Linux
Download ta-lib-0.4.0-src.tar.gz and: $ untar and cd $ ./configure --prefix=/usr $ make $ sudo make install If you build TA-Lib using make -jX it will fail but that’s OK! Simply rerun make -jX followed by [sudo] make install.

truf
  • 2,843
  • 26
  • 39
  • Thanks for your response. I did what the official site says to install on Linux and make a lot of things, but then tried to "import talib" and didn't find the module. After, I make a pip install again and it worked, for anyone that have the problem, please try that. Thanks – cristianc Apr 12 '19 at 16:24
0

ta-lib depends on their C implementation you have to install it before installing the python version.