Matplotlib no longer works due to interactive issue

I worked with python and matplotlib, but my script crashed, so I had to disable the terminal (Ubuntu 12.04, matplotib-1.1.0, python2.7). Now, if I try to run any script, it will work on the line

import matplotlib.pyplot as plt 

with the following error

 Traceback (most recent call last): File "new.py", line 4, in <module> import matplotlib.pyplot as plt File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/__init__.py", line 151, in <module> from matplotlib.rcsetup import (defaultParams, File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/rcsetup.py", line 20, in <module> from matplotlib.colors import is_color_like File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/colors.py", line 54, in <module> import matplotlib.cbook as cbook File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/cbook.py", line 32, in <module> import new File "/home/federico/Documents/doc_uni/idraulica_ambientale/relazione/scripts/variabili/new.py", line 4, in <module> import matplotlib.pyplot as plt File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/pyplot.py", line 23, in <module> from matplotlib import _pylab_helpers, interactive ImportError: cannot import name interactive 

Pay attention to the last line. I tried uninstalling and reinstalling matplotlib from both the source and from pip and easy_install, but I cannot handle it. The same error occurs if I try to import from a python interpreter. I also installed version 1.2.0 to make sure this works, but it doesn’t.

+6
source share
1 answer

If you are viewing files in a stack trace,

new.py β†’ /matplotlib/__init__.py β†’ matplotlib/rcsetup.py , /matplotlib/colors.py β†’ /matplotlib/cbook.py β†’ /home/federico/Documents/../new.py β†’ matplotlib/pyplot.py

You named your module new , which obscures with import in matplolib.cbook , which makes you try to import pyplot while you import pyplot , which is clearly exploding (which is why it is above my paygrade). You just need to rename your module to something other than new.py (and don't forget to delete the created new.pyc file).

As a test run, import matplotlib.pyplot as plt in an interactive shell.

FYI is> what you obscure.

This import will be removed in mpl 1.3

+9
source

All Articles