ta-lib-python
ta-lib-python copied to clipboard
How to install the ta-lib with Anaconda?
I have tried use the following to install the ta-lib in Anaconda: ... conda install -c quantopian ta-lib ...
But I get message as follow:
Fetching package metadata ............. Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- python 3.6*
- ta-lib -> numpy 1.10* -> python 2.7*
Use "conda info
" to see the dependencies for each package.
How to do?
I'm not sure. In the requirements.txt
, it looks like we specify some old versions numpy==1.11.1
and cython==0.24.1
. Not sure where you're seeing numpy 1.10*.
What happens if you do condo info ta-lib
?
This is what I get:
C:\ProgramData\Anaconda3\Scripts>conda.exe info ta-lib Fetching package metadata ........... NoPackagesFoundError: Package missing in current win-64 channels:
- ta-lib
Btw: Is talib from Quantopian?
No, this is not a Quantopian project. And this is just a lightweight wrapper for a "TA-Lib" C library that has been around for 15 years or so.
Ah, well your conda thing is probably a different issue. Since the underlying TA-Lib library isn't released as 64-bit binary on Windows, you have to build it yourself. Or get a pre-built binary that you can use.
Here is a comment from someone getting it to work with Anaconda 64-bit and the previous comment in that thread has some instructions on how to build it yourself if you don't want to trust whatever binary that download is.
@mrjbq7 I think I fix the problem now. This page is very helful, though it is unofficial. http://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
try:
conda install -c quantopian ta-lib
^ it is depreciated for python 3.6
I'm currently working on a conda-forge recipe for this library: https://github.com/conda-forge/staged-recipes/pull/5772
So far, I have created Windows 64 recipes (for ta-lib 0.4.16) only. It would be nice if someone could give it a try:
Install:
conda install -c masdeseiscaracteres ta-lib
Testing:
- Install nose
pip install nose
- Run tests
nosetests -v talib
If everything goes alright, the following is expected:
talib.test_abstract.test_pandas ... ok
talib.test_abstract.test_SMA ... ok
talib.test_abstract.test_STOCH ... ok
talib.test_abstract.test_doji_candle ... ok
talib.test_abstract.test_MAVP ... ok
talib.test_abstract.test_info ... ok
talib.test_abstract.test_input_names ... ok
talib.test_abstract.test_input_arrays ... ok
talib.test_abstract.test_parameters ... ok
talib.test_abstract.test_lookback ... ok
talib.test_func.test_talib_version ... ok
talib.test_func.test_num_functions ... ok
talib.test_func.test_input_lengths ... ok
talib.test_func.test_input_nans ... ok
talib.test_func.test_unstable_period ... ok
talib.test_func.test_MIN ... ok
talib.test_func.test_MAX ... ok
talib.test_func.test_MOM ... ok
talib.test_func.test_BBANDS ... ok
talib.test_func.test_DEMA ... ok
talib.test_func.test_EMAEMA ... ok
talib.test_func.test_CDL3BLACKCROWS ... ok
talib.test_func.test_RSI ... ok
talib.test_func.test_MAVP ... ok
talib.test_stream.test_streaming ... ok
talib.test_stream.test_CDL3BLACKCROWS ... ok
----------------------------------------------------------------------
Ran 26 tests in 0.131s
@masdeseiscaracteres
`Solving environment: done
Package Plan
environment location: C:\ProgramData\Anaconda3
added / updated specs: - ta-lib
The following packages will be downloaded:
package | build
---------------------------|-----------------
ta-lib-0.4.16 | py36_0 652 KB masdeseiscaracteres
The following NEW packages will be INSTALLED:
ta-lib: 0.4.16-py36_0 masdeseiscaracteres
The following packages will be UPDATED:
ca-certificates: 2017.08.26-h94faf87_0 --> 2018.03.07-0
certifi: 2017.7.27.1-py36h043bc9e_0 --> 2018.4.16-py36_0
openssl: 1.0.2l-vc14hcac20b0_2 --> 1.0.2o-h8ea7d77_0
Proceed ([y]/n)? y
Downloading and Extracting Packages ta-lib 0.4.16################################################################################################## | 100% Preparing transaction: done Verifying transaction: done Executing transaction: failed ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::certifi-2017.7.27.1-py36h043bc9e_0'. PermissionError(13, 'Accesso negato') Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Accesso negato')`
It seems something unrelated to TA-lib, it went wrong while uninstalling certifi
. Close all Python sessions, IDEs, or Python-related running processes and try again.
I installed it via pip, getting this wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs Now I have ta-lib working with python 3.6 Hope this helps someone else
Yep, that works, but this issue is about installing TA-lib using Anaconda. Having a well-tested and well-defined publicly available build process to build conda recipes is also useful to build pip wheels. This will help not only Windows users but those in Unix systems as well.
@masdeseiscaracteres it works on windows 10, 64 bit, using miniconda4 and pyhton36.
Cool! Let's go then for the win32 and Unix wheels
it shows me that the python doesnot support that type of wheel format I am using windows 8 64 bit version with python3.6
Which is the bitness of your Python interpreter? When starting the Python interpreter in the terminal/command line you may see a line like:
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
What does yours say?
python 3.6.5 32 bit compiler on win32
That's it then. The packages in https://anaconda.org/masdeseiscaracteres/TA-Lib/files?type=conda are only for 64 bit Python. I have been told conda-forge no longer supports 32 bit builds.
Great! talib running on my Windows10 machine, conda64 and python 3.6 Already made all 26 tests with OK result and run a simple test code calculating some simple indicators.. Thanks a lot
But look at this..interesting..it seems that maybe is it not installed properly? Module 'talib' has no 'EMA' member
@masdeseiscaracteres here with Windows 10 64bit and Python 3.6 install so fine. Now, I'will test the lib work.
#AllForABetterBrazil
example:
upperband, middleband, lowerband = ta.BBANDS(df['Close'], timeperiod=n, nbdevup=2, nbdevdn=2, matype=0)
Module 'talib' has no 'EMA' member
Module 'talib' has no 'BBANDS' member
but the tests went ok.. what´s wrong?
@jorgeog96 Are you trying to import it from a python shell that was started from the git checkout directory? That would cause it to find/load the wrong ta-lib module.
I am not pretty sure...but you´re right! If I trying to reproduce the code using jupyter notebook (but my same environment) the thing is OK! but using visual studio code with that environment in an anaconda terminal (inside VS) the code is wrong and get the wrong module. What is the problem?
You can see where the module code is loading from:
This is what a "system" install would generally look like:
>>> import talib
>>> talib.__file__
'/usr/local/lib/python3.6/site-packages/talib/__init__.py'
This is what "loading from a git checkout" might look like:
>>> import talib
>>> talib.__file__
'/home/username/ta-lib/talib/__init__.py'
ok, thank u for your help @mrjbq7 , definitely it´s the first way with the "system" install. I´ve tried in both terminals: original anaconda prompt and visual studio anaconda integrated prompt (where I usually code and try out my scripts). So, how can I fix that import error from the scripts written when I use visual studio code?
This is really curious: I import talib package as ta and then I add code to do a RSI calculation using ta.RSI (i.e.):
rsi2 = ta.RSI(df.Close.values,14)
The thing is that VSCode is giving me error saying: E1101:Module 'talib' has no 'RSI' member. But when I use my command prompt Anaconda in VSCode and run: python printPair.py IS RUNNING and calculating the array rsi2 perfectly!
I am comparing the values given from talib with a rsi function "hand-made" and the values are the same. So this is really weird. Maybe it is VSCode python interpreter fault? or something like that? Maybe python interpreter from VSCode is using a "loading from a git checkout"? and getting the wrong package? Because anaconda prompt is running ok! @mrjbq7
I'm not sure how your VSCode is setup, but maybe if you print out:
>>> import sys
>>> sys.path
You can see where the code is being loaded from...
conda install -c developer ta-lib
conda install -c quantopian ta-lib depend on python2 version but I use python3 conda install -c developer ta-lib is OK! My system is osx.
@masdeseiscaracteres
Your solulion worked. Ran Admin anaconda prompt....
base) C:\WINDOWS\system32>conda install -c masdeseiscaracteres ta-lib Solving environment: done
Package Plan
environment location: C:\ProgramData\Anaconda3
added / updated specs: - ta-lib
The following NEW packages will be INSTALLED:
mkl_fft: 1.0.6-py36hdbbee80_0
mkl_random: 1.0.1-py36h77b88f5_1
numpy-base: 1.15.4-py36h8128ebf_0
ta-lib: 0.4.16-py36_0 masdeseiscaracteres
The following packages will be UPDATED:
numpy: 1.14.0-py36h4a99626_1 --> 1.15.4-py36ha559c80_0
The following packages will be DOWNGRADED:
mkl: 2019.0-118 --> 2018.0.3-1
Proceed ([y]/n)? y
Preparing transaction: done Verifying transaction: done Executing transaction: done
(base) C:\WINDOWS\system32>
Nose test...
C:\Users\GUEST1>nosetests -v talib talib.test_abstract.test_pandas ... ok talib.test_abstract.test_SMA ... ok talib.test_abstract.test_STOCH ... ok talib.test_abstract.test_doji_candle ... ok talib.test_abstract.test_MAVP ... ok talib.test_abstract.test_info ... ok talib.test_abstract.test_input_names ... ok talib.test_abstract.test_input_arrays ... ok talib.test_abstract.test_parameters ... ok talib.test_abstract.test_lookback ... ok talib.test_func.test_talib_version ... ok talib.test_func.test_num_functions ... ok talib.test_func.test_input_lengths ... ok talib.test_func.test_input_nans ... ok talib.test_func.test_unstable_period ... ok talib.test_func.test_MIN ... ok talib.test_func.test_MAX ... ok talib.test_func.test_MOM ... ok talib.test_func.test_BBANDS ... ok talib.test_func.test_DEMA ... ok talib.test_func.test_EMAEMA ... ok talib.test_func.test_CDL3BLACKCROWS ... ok talib.test_func.test_RSI ... ok talib.test_func.test_MAVP ... ok talib.test_stream.test_streaming ... ok talib.test_stream.test_CDL3BLACKCROWS ... ok
Ran 26 tests in 0.050s
and functions work in my jupyter notebook
import pandas_datareader.data as web import pandas as pd import numpy as np import talib import matplotlib.pyplot as plt #Added Imports Below import fbprophet import pytrends from pytrends.request import TrendReq #adds fix for workaround from quandl import fix_yahoo_finance as fyf fyf.pdr_override() start = '2010-04-22' end = '2018-11-28' ticker = 'AMZN' max_holding = 100 #price = web.DataReader(name=symbol, data_source='quandl', start=start, end=end) stock = web.get_data_yahoo(ticker, start, end) #stock.head() stock = stock.iloc[::-2] stock = stock.dropna() adjclose = stock['Adj Close'].values
type(adjclose) #adjclose is numpy.ndarray
#up, mid, low = talib.BBANDS(adjclose, timeperiod=30, nbdevup=2, nbdevdn=2, matype=0) rsi = talib.RSI(adjclose, timeperiod=14) print("RSI (first 10 elements)\n", rsi[14:24])
Output below... [100%**] 1 of 1 downloaded RSI (first 10 elements) [54.71139616 57.02129463 55.09458265 53.04076073 58.49369522 60.52833881 63.20019195 64.52435953 62.37719531 59.31951051]
conda install -c quantopian ta-lib depend on python2 version but I use python3 conda install -c developer ta-lib is OK! My system is osx.
happyHou, this is great, how do I create a new conda package for python 3.7? Any pointers appreciated.
conda install -c masdeseiscaracteres ta-lib
I tried it on Linux Ubuntu 16.04:
Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- ta-lib
Current channels:
- https://conda.anaconda.org/masdeseiscaracteres/linux-64
- https://conda.anaconda.org/masdeseiscaracteres/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
conda install -c quantopian ta-lib depend on python2 version but I use python3 conda install -c developer ta-lib is OK! My system is osx.
what version of python are you using? It is not working on my 3.7.
No, this is not a Quantopian project. And this is just a lightweight wrapper for a "TA-Lib" C library that has been around for 15 years or so.
Ah, well your conda thing is probably a different issue. Since the underlying TA-Lib library isn't released as 64-bit binary on Windows, you have to build it yourself. Or get a pre-built binary that you can use.
Here is a comment from someone getting it to work with Anaconda 64-bit and the previous comment in that thread has some instructions on how to build it yourself if you don't want to trust whatever binary that download is.
[Windows 10, 64 bit, Anaconda ]I am using windows 10 64bit, when I tried to install ta-lib faced similar issues however this youtube video([https://www.youtube.com/watch?v=VJyNArEU0ws&ab_channel=QuantAlpha]) solved all of my issues and now I am using ta-lib in my anaconda environment just fine. hope this helps