2016-07-07 155 views
1

當在運行Python 3.5.2的Jupyter筆記本中使用yHat的Python ggplot庫(請參閱下面的完整錯誤)時,我得到NameError: name 'unicode' is not defined。用下面的import語句:Python 3.5 Jupyter筆記本ggplot「名稱錯誤」

%matplotlib inline 
from ggplot import * 

圖形渲染依舊,但我想,以消除誤差,或隱藏如果不引起大的衝突。

完整的錯誤如下。非常感謝提前:) :)

--------------------------------------------------------------------------- 
NameError         Traceback (most recent call last) 
//anaconda/lib/python3.5/site-packages/IPython/core/formatters.py in __call__(self, obj) 
    697     type_pprinters=self.type_printers, 
    698     deferred_pprinters=self.deferred_printers) 
--> 699    printer.pretty(obj) 
    700    printer.flush() 
    701    return stream.getvalue() 

//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in pretty(self, obj) 
    381        if callable(meth): 
    382         return meth(obj, self, cycle) 
--> 383    return _default_pprint(obj, self, cycle) 
    384   finally: 
    385    self.end_group() 

//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in _default_pprint(obj, p, cycle) 
    501  if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs: 
    502   # A user-provided repr. Find newlines and replace them with p.break_() 
--> 503   _repr_pprint(obj, p, cycle) 
    504   return 
    505  p.begin_group(1, '<') 

//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle) 
    692  """A pprint that just redirects to the normal repr function.""" 
    693  # Find newlines and replace them with p.break_() 
--> 694  output = repr(obj) 
    695  for idx,output_line in enumerate(output.splitlines()): 
    696   if idx: 

//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in __repr__(self) 
    113   Evaluates patsy expressions within the aesthetics. For example, 'x + 1' 
    114   , 'factor(x)', or 'pd.cut(price, bins=10)') 
--> 115   """ 
    116   for key, item in self._aes.items(): 
    117    if item not in self.data: 

//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in make(self) 

//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in apply_axis_labels(self) 
    269     i, j = self.subplots.shape 
    270     i, j = int((i - 1)/2), int(j - 1) 
--> 271     ax = self.subplots[i][j] 
    272     make_legend(ax, legend) 
    273    elif self.facets.rowvar: 

NameError: name 'unicode' is not defined 
+1

它可能不是PY3保存修復此相同的問題:https://github.com/yhat/ggplot/blob /b6492aaff6aae5301fa838a24e4416c092e03f24/ggplot/ggplot.py#L271->測試也不是py3保存,所以我想它只是py2 ... –

回答

1

如果您安裝了anaconda,請嘗試安裝code-forge版本。我能夠通過切換到該版本爲Python 3.5

conda install -c conda-forge ggplot

希望幫助

+0

謝謝,我會試試這個。我最終爲Jupyter添加了Python 2.7內核,然後在2.7而不是3.5.2上運行ggplot – typeofgraphic