3

I have a fresh install of Ubuntu 13.04 and am trying to use the python library matlibplot. I installed it via sudo apt-get install python-matplotlib and this seemed to be successful. However, then I try to run a python script with import matplotlib, I get the following exception message:

Traceback (most recent call last):
  File "./simulate.py", line 6, in <module>
    import matplotlib
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 165, in <module>
    from matplotlib.rcsetup import (defaultParams,
  File "/usr/lib/pymodules/python2.7/matplotlib/rcsetup.py", line 20, in <module>
    from matplotlib.colors import is_color_like
  File "/usr/lib/pymodules/python2.7/matplotlib/colors.py", line 54, in <module>
    import matplotlib.cbook as cbook
  File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 34, in <module>
    import new
  File "/home/rob/Dropbox/Fourth Year/algo/git/new.py", line 3, in <module>
    from pylab import *
  File "/usr/lib/pymodules/python2.7/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.7/matplotlib/pylab.py", line 219, in <module>
    from cbook import flatten, is_string_like, exception_to_str, \
ImportError: cannot import name flatten

This has happened previously (and I was not able to get around it). There does not seem anyone who has had the same problem.

Does anyone know of a solution?

1 Answer 1

2

The problem was that I had a file called new.py in the same directory.

Its worth noting that you need to remove that and new.pyc to fix the issues.

Sign up to request clarification or add additional context in comments.

1 Comment

Good catch. You've taught me to actually read the file names in tracebacks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.