vectorbt
vectorbt copied to clipboard
AttributeError: type object 'DOMWidget' has no attribute '_ipython_display_'
I am running this in jupyter lab and getting following error
import vectorbt as vbt
import yfinance
cols = ['Open', 'High', 'Low', 'Close', 'Volume']
ohlcv = vbt.YFData.download("BTC-USD").get(cols)
ohlcv.vbt.ohlcv.plot()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~\.conda\envs\vectorbacktest_env\lib\site-packages\IPython\core\formatters.py:921, in IPythonDisplayFormatter.__call__(self, obj)
919 method = get_real_method(obj, self.print_method)
920 if method is not None:
--> 921 method()
922 return True
File ~\.conda\envs\vectorbacktest_env\lib\site-packages\plotly\basewidget.py:741, in BaseFigureWidget._ipython_display_(self)
737 """
738 Handle rich display of figures in ipython contexts
739 """
740 # Override BaseFigure's display to make sure we display the widget version
--> 741 widgets.DOMWidget._ipython_display_(self)
AttributeError: type object 'DOMWidget' has no attribute '_ipython_display_'
@shaktisd pip install "jupyterlab>=3" "ipywidgets>=7.6"
, then pip install plotly==5.10.0
, then run JupyterLab again.
@polakowo - Thanks this seems to work , as I can see the graph but the error still comes . Is there a way to remove that also ?
I was having exactly this problem in Jupyter notebook. In case it helps someone else, the workaround that eliminated the problem for me, after following the plotly recommendation
$ pip install "notebook>=5.3" "ipywidgets>=7.5"
was by downgrading these packages:
pip install ipywidgets==7.7.1 and jupyterlab-widgets==1.1.1
as per this answer https://github.com/plotly/plotly.py/issues/3686#issuecomment-1220658377. Probably it's the ipywidgets downgrade that fixes it. I know I was previously on ipywidgets>=8.0.0, not sure of the previous jupyterlab-widgets version.
@polakowo - Thanks this seems to work , as I can see the graph but the error still comes . Is there a way to remove that also ?
You can use ohlcv.vbt.ohlcv.plot().show()
, by adding show method, it will remove the error message. It worked for me.
Downgraded to ipywidgets==7.7.1
to workaround this issue.
Can confirm ipywidgets==7.7.2 works too.