Search code examples
pythonmatplotlibcloud9-ide

Using matplotlib on Cloud 9 Ide


I'm trying to use matplotlib on Cloud9 ide, but here's what happens:

    >>> import matplotlib
    >>> matplotlib.use('Agg')
    >>> from matplotlib import pyplot
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 24, in <module>
        import matplotlib.colorbar
      File "/usr/lib/pymodules/python2.7/matplotlib/colorbar.py", line 29, in <module>
        import matplotlib.collections as collections
      File "/usr/lib/pymodules/python2.7/matplotlib/collections.py", line 23, in <module>
        import matplotlib.backend_bases as backend_bases
      File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 50, in <module>
        import matplotlib.textpath as textpath
      File "/usr/lib/pymodules/python2.7/matplotlib/textpath.py", line 5, in <module>
        import urllib
      File "/usr/lib/python2.7/urllib.py", line 26, in <module>
        import socket
      File "socket.py", line 5, in <module>
        This module provides socket operations and some related functions.
    AttributeError: 'module' object has no attribute 'AF_INET'

The Cloud9 Support people have told me that there's nothing wrong with my platform and that matplotLib might not support being initialized within an environment that only has console access. However I remember using matplotlib in the exact same way on Cloud9 about a year ago.

Could anyone explain to me what exactly this error means and if there is a way to get around it?


Solution

  • It seems this is an older version of matplotlib.

    Take a note on commit f4adec7 from Aug 2013 where "import urllib" line has been removed from textpath.py. This change is present as early as in matplotlib v1.4.0.