KeyError:'plotly_domain'

Posted

技术标签:

【中文标题】KeyError:\'plotly_domain\'【英文标题】:KeyError: 'plotly_domain'KeyError:'plotly_domain' 【发布时间】:2016-12-02 01:42:58 【问题描述】:

我正在运行来自here的代码:

import plotly
import plotly.plotly as py
from plotly.tools import FigureFactory as FF

import numpy as np
import pandas as pd
print(plotly.__version__)
dataframe = pd.DataFrame(np.random.randn(100, 3),
                         columns=['Column A', 'Column B', 'Column C'])

fig = FF.create_scatterplotmatrix(dataframe, diag='histogram', index='Column A',
                                  colormap=['rgb(100, 150, 255)', '#F0963C', 'rgb(51, 255, 153)'],
                                  colormap_type='seq', height=800, width=800)
py.iplot(fig, filename = 'Custom Sequential Colormap')

我得到这个错误:

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/mona/PycharmProjects/PythonCodes/plotly_viz.py
1.12.4
This is the format of your plot grid:
[ (1,1) x1,y1 ]  [ (1,2) x2,y2 ]
[ (2,1) x3,y3 ]  [ (2,2) x4,y4 ]

Traceback (most recent call last):
  File "/Users/mona/PycharmProjects/PythonCodes/plotly_viz.py", line 14, in <module>
    py.iplot(fig, filename = 'Custom Sequential Colormap')
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/plotly/plotly/plotly.py", line 175, in iplot
    return tools.embed(url, **embed_options)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/plotly/tools.py", line 443, in embed
    != session.get_session_config()['plotly_domain']):
KeyError: 'plotly_domain'

Process finished with exit code 1

您知道问题是什么以及如何解决吗?我一直在尝试,但即使我的第一次尝试也碰巧不成功!

【问题讨论】:

【参考方案1】:

根据这个答案,尝试使用py.plot 而不是py.iplot

KeyError: 'plotly_domain' when using plotly to do scatter plot in python

原因是iplot 用于 ipython 会话。

【讨论】:

以上是关于KeyError:'plotly_domain'的主要内容,如果未能解决你的问题,请参考以下文章

Pytorch:“KeyError:在 DataLoader 工作进程 0 中捕获 KeyError。”

字典的用法

为啥 str(KeyError) 添加额外的引号?

为啥我收到此错误? KeyError:“没有”

KeyError : 0 熊猫

python3 日志检索异常抛出异常 raise KeyError(key),KeyError: 'formatters'