开始使用时导入错误

时间:2014-08-16 18:36:30

标签: python plot ipython plotly

我正在尝试使用plotly,基于这里的教程:http://nbviewer.ipython.org/github/plotly/python-user-guide/blob/master/s00_homepage/s00_homepage.ipynb

似乎有正确的库和Python版本,虽然我在导入时得到了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'

1 个答案:

答案 0 :(得分:4)

我有类似的错误,并按照上面的Mark的说明,pip install --upgrade plotly为我工作。