我正在研究使用 IBM Watson Machine Learning 预测户外设备购买的演示笔记本。我将笔记本复制到一个项目中并开始逐个单元格地运行。
一切都很顺利,除了当我进入第5.2 节:使用 Plotly 包的数据可视化示例。
在本节中,首先安装一些库:
!pip install plotly --user
!pip install cufflinks --user
接着 ...
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"]]))
这导致:
ImportError: No module named talib
所以我修改了 pip 命令并重新运行:
!pip install plotly --user --upgrade
!pip install cufflinks --user --upgrade
当我重新运行绘图代码时,我得到:
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
更新:我尝试修复袖扣库版本:
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