开始使用 plotly 时导入错误
Posted
技术标签:
【中文标题】开始使用 plotly 时导入错误【英文标题】:Import error when starting to use plotly 【发布时间】:2014-10-10 03:36:23 【问题描述】:我正在尝试使用 plotly,基于此处的教程:http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s00_homepage/s00_homepage.ipynb
似乎有正确的库和 Python 版本,虽然我在 plotly 导入时遇到了 AttributeError。想知道是否有人遇到同样的问题,请参阅下面的版本和堆栈跟踪:
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import numpy
In [2]: numpy.__version__
Out[2]: '1.8.1'
In [3]: import pandas
In [4]: pandas.__version__
Out[4]: '0.13.1'
In [5]: import plotly
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-c27a4132ad2e> in <module>()
----> 1 import plotly
/usr/local/lib/python2.7/dist-packages/plotly/__init__.py in <module>()
29 from __future__ import absolute_import
30
---> 31 from plotly import plotly, graph_objs, tools, utils
32 from plotly.version import __version__
/usr/local/lib/python2.7/dist-packages/plotly/plotly/__init__.py in <module>()
10 from __future__ import absolute_import
11
---> 12 from plotly.plotly.plotly import *
13
14 __all__ = ["sign_in", "update_plot_options", "get_plot_options",
/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py in <module>()
27 from plotly.plotly import chunked_requests
28 from plotly import utils
---> 29 from plotly import tools
30 from plotly import exceptions
31 from plotly import version
/usr/local/lib/python2.7/dist-packages/plotly/tools.py in <module>()
18 from plotly import exceptions
19
---> 20 from . graph_objs import graph_objs
21
22 # Warning format
/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/__init__.py in <module>()
10 from __future__ import absolute_import
11
---> 12 from plotly.graph_objs.graph_objs import *
13
14 __all__ = ["Data",
/usr/local/lib/python2.7/dist-packages/plotly/graph_objs/graph_objs.py in <module>()
279 return super(DictMeta, mcs).__new__(mcs, name, bases, attrs)
280
--> 281 @six.add_metaclass(ListMeta)
282 class PlotlyList(list):
283 """A container for PlotlyDicts, inherits from standard list.
AttributeError: 'module' object has no attribute 'add_metaclass'
【问题讨论】:
如果你先import six
,然后six
,它会说它安装在哪里?您可能有一个 six.py
文件,而不是 six 包。
原因是我错过了“pip install --upgrade plotly”,它终于也升级了所有必要的依赖项。
【参考方案1】:
我遇到了类似的错误,按照上面 Mark 的说明,pip install --upgrade plotly
为我工作。
【讨论】:
以上是关于开始使用 plotly 时导入错误的主要内容,如果未能解决你的问题,请参考以下文章
SQL Server 2005导入数据时出错,导入的是TXT文本格式
SQL Server 2005 DTS导入平面数据源时(如txt文档),总是被截断,无法执行的错误解决方案
mysql导入大量数据时报MySQL server has gone away错误的解决办法