0

This is a rather weird problem. I'm on Windows and using Anaconda for Python. There is a financial tool library called TA_lib (Technical Analysis Library). Since this library is not officially supported, I had to install a whl version and I got it from here.

After installation I was able to use it. But sometimes, when I start Anaconda and Spyder, the import talib command yields "Talib has no functiona as ..." and I cannot import and use it. When this happens, I follow these steps:

  1. I close Anaconda and Spyder
  2. I install the library again through Anaconda prompt (I see requirement already satisfied messge)
  3. I restart Anaconda and Spyder

If I'm lucky, I can import talib after first try. If not, I have to repeat these steps for a couple of times. What might be wrong?

EDIT 1:

Now it's not working. Here is the error log:

import pandas as pd
import talib
import numpy as np
Traceback (most recent call last):

  File "<ipython-input-2-a3bb601353da>", line 2, in <module>
    import talib

  File "C:\Users\ismetb\Desktop\AlgoritmikFinans\Classifier 11-12-2018 1830 v2\talib.py", line 90, in <module>
    upperband, middleband, lowerband = talib.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=talib.MA_Type.T3)

AttributeError: module 'talib' has no attribute 'BBANDS'
iso_9001_
  • 2,655
  • 6
  • 31
  • 47

2 Answers2

0

There is a chance you've installed it wrong. Also consider that this is an unofficial library.

Make sure you installed the correct TA_lib for your Python version. What Python version are you using? If it's 3.4, make sure you have downloaded the TA_lib cp34 for windows 64 bits or 32 bits. If it's another version, make sure you find the one appropriate to you.

Also another useful link to download TA_lib for 64bit is here.

Iulian
  • 409
  • 3
  • 17
  • 1
    I believe I did not install it wrong since I've been using it for a long time. But, not always :) I am using the library but sometimes I cannot import it. That's my problem. All version, bit etc controls are OK. – iso_9001_ Dec 12 '18 at 22:00
0

I figured the problem. My Python file name was Talib_pure and then I renamed it to Talib. Since I import talib with import talib command, Python tried to import my own code isntead of talib library and therefore it got confused.

I renamed the file to ta_lib and now it works (so far at least).

iso_9001_
  • 2,655
  • 6
  • 31
  • 47