Python matplotlib not importing due to failure to import unichr
Question: I'm running Ubuntu 13.10 with Python 2.7.5+, and whenever I try to import the
`matplotlib` package, I get an error. Specifically, my test script has only
the following code:

    
    
    #!/usr/bin/python
    import matplotlib.pyplot as plt
    

When I run the test script, here is the error:

    
    
    Traceback (most recent call last):
      File "./test.py", line 2, in <module>
        import matplotlib.pyplot as plt
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
        import matplotlib.colorbar
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 34, in <module>
        import matplotlib.collections as collections
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/collections.py", line 27, in <module>
        import matplotlib.backend_bases as backend_bases
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 56, in <module>
        import matplotlib.textpath as textpath
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/textpath.py", line 22, in <module>
        from matplotlib.mathtext import MathTextParser
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/mathtext.py", line 26, in <module>
        from six import unichr
    ImportError: cannot import name unichr
    

Any idea what I'm doing wrong?


Answer: You apparently have an outdated version of `six`.

The `unichr` wrapper was added in version 1.4.0, as seen in
[`CHANGES`](https://bitbucket.org/gutworth/six/src/default/CHANGES?at=default#cl-135).
I'm not sure exactly when 1.4.0 was released, but the fix for [issue
#25](https://bitbucket.org/gutworth/six/issue/25/add-unichr) was committed on
2013-05-18, so… some time after that.

So, if you `print(six.__version__)`, and it's anything less than '1.4.0',
that's your problem.

Depending on whether you're installing packages with `pip` or with your
system's package manager, the solution is going to be something like one of
these:

    
    
    $ pip install --upgrade six
    $ apt-get install six
    $ brew install --upgrade six
    

… etc.

* * *

But meanwhile, `matplotlib` shouldn't be requiring 1.3 but using features only
available in 1.4. Your GitHub issue
[matplotlib#3538](https://github.com/matplotlib/matplotlib/issues/3538) should
get this fixed.

