0

I'm working through the demo notebook Predict outdoor equipment purchase with IBM Watson Machine Learning. I copied the notebook into a project and started running cell by cell.

All was going well except when I got to the section 5.2: Sample visualization of data with Plotly package.

In this section, first, some libraries are installed:

!pip install plotly --user 
!pip install cufflinks --user

And then ...

import sys
import pandas
import plotly.plotly as py
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import cufflinks as cf
import plotly.graph_objs as go
init_notebook_mode(connected=True)
sys.path.append("".join([os.environ["HOME"]]))

This resulted in:

ImportError: No module named talib

So I modified the pip commands and rerun:

!pip install plotly --user --upgrade
!pip install cufflinks --user  --upgrade

When I rerun the plotting code, I get:

ImportErrorTraceback (most recent call last)
<ipython-input-4-6838ef923a0d> in <module>()
      3 import plotly.plotly as py
      4 from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
----> 5 import cufflinks as cf
      6 import plotly.graph_objs as go
      7 init_notebook_mode(connected=True)

/gpfs/fs01/user/s15a-8ea34840daaa3e-39ca506ba762/.local/lib/python2.7/site-packages/cufflinks/__init__.py in <module>()
      9 from __future__ import absolute_import
     10 
---> 11 from . import date_tools
     12 from . import utils
     13 from . import datagen

ImportError: cannot import name date_tools

Update: I tried fixing the cufflinks library version:

Successfully installed cufflinks-0.8.2

ImportErrorTraceback (most recent call last)
<ipython-input-36-d76e85e800c3> in <module>()
      5 import plotly.plotly as py
      6 from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
----> 7 import cufflinks as cf
      8 import plotly.graph_objs as go
      9 init_notebook_mode(connected=True)

/gpfs/fs01/user/s15a-8ea34840daaa3e-39ca506ba762/.local/lib/python2.7/site-packages/cufflinks/__init__.py in <module>()
      8 """
      9 
---> 10 from . import date_tools
     11 from . import utils
     12 from . import datagen

ImportError: cannot import name date_tools
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • I was able to reproduce this issue on other environment than DSX. I also see that the issue is related to cufflinks package https://github.com/santosjorge/cufflinks/issues/65#issue-238564960 – charles gomes Jun 26 '17 at 20:47

1 Answers1

1

The issue you ran into appears when different version of cufflinks library is used.

This should fix !pip install cufflinks==0.8.2 --user

  • Unfortunately it didn't work :( - I've updated the question to reflect this. – Chris Snow Jul 03 '17 at 08:37
  • Could you please use "!pip freeze" to check you lib versions? Here is what I have in my notebook (Python 2 with Spark 2.1): colorlover==0.2.1, cufflinks==0.8.2, plotly==2.0.12. You can also share your notebook so I can have a look. – Umit Mert Cakmak Jul 05 '17 at 10:47
  • I have just restarted my kernel and retried and it works ok. Many thanks! – Chris Snow Jul 05 '17 at 11:12