1
votes

I am getting NameError: name 'unicode' is not defined when using yHat's ggplot library for Python (see full error below) in a Jupyter Notebook, running Python 3.5.2. with the following import statements:

 %matplotlib inline
from ggplot import * 

The graph still renders, but I would like to eliminate the error, or hide it if its not causing a major conflict.

The full error is below. Many thanks in advance :)

---------------------------------------------------------------------------
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
It's probably not py3 save: github.com/yhat/ggplot/blob/… -> The tests are also not py3 save, so I guess it is py2 only... - Jan Katins

1 Answers

1
votes

If you have anaconda installed try installing the code-forge version. I was able to fix this same problem by switching to that version for python 3.5

conda install -c conda-forge ggplot

Hope that helps