Russo
Russo

Reputation: 3022

importerror cannot import name candlestick

I got an error message from Python:

Traceback (most recent call last):  
  File "stock_script.py", line 9, in <module>  
    from matplotlib.finance import candlestick  
ImportError: cannot import name candlestick

Why?

Upvotes: 3

Views: 3939

Answers (3)

Floyd
Floyd

Reputation: 789

Not very nice changing the name and breaking existing code...

I have fixed this by changing the import like this.

from matplotlib.finance import candlestick_ohlc as candlestick

No further changes are then needed in the code.

Upvotes: 1

William Ross
William Ross

Reputation: 3910

You need to add an underscore to it to use this same library:

from matplotlib.finance import _candlestick

Upvotes: 0

Russo
Russo

Reputation: 3022

Matplotlib code has been changed... Go into the script and replace "candlestick" by "candlestick_ohlc"

So it should read:

from matplotlib.finance import candlestick_ohlc

candlestick_ohlc(ax1, ...

Upvotes: 2

Related Questions