3

I am running an Anaconda installation of Python3 64bit on Windows. I have no idea how to put those words in a proper sentence, but I hope it gives enough information. I am taking an Udacity course which wants me to run %matplotlib inline. This gives the following error:

AttributeError: module 'matplotlib' has no attribute 'colors'

I get the same error when I run from matplotlib import pylab, but i get no error from import matplotlib.

I installed matplotlib as follows: conda install -n tensorflow -c conda-forge matplotlib.

How do I solve this error?

Kind regards

Per request:
conda list gives

matplotlib 2.1.0 py36_1 conda-forge

and a list of other modules.

Vincent Lous
  • 127
  • 1
  • 1
  • 6
  • Although I don't think this is the cause of the problem, you're missing the `-c` before `conda-forge`. Is that a typo? Can you show the output of `conda list`? – darthbith Nov 26 '17 at 14:49
  • Thanks. The ``-c`` was a typo. I assumed you only wanted the matplotlib part of ``conda list``. Let me know if you want to see more. – Vincent Lous Nov 26 '17 at 20:34
  • Are you running the magic command (`%matplotlib inline`) in a Notebook, or IPython? In either case, did you install the relevant package to the `tensorflow` environment and activate the environment before running the commands? – darthbith Nov 26 '17 at 22:10
  • I am running the magic command from a jupyter notebook which I started by ``activate tensorflow`` and then ``jupyter-notebook``. The matplotlib package is installed to the ``tensorflow`` environment (see the ``-n`` flag in the ``conda install`` command). – Vincent Lous Nov 27 '17 at 13:45
  • Did you install the Jupyter Notebook to the `tensorflow` environment? Also, the command to start the notebook is `jupyter notebook` not `jupyter-notebook`. – darthbith Nov 27 '17 at 14:21
  • I installed the Jupyter Notebook to the tensorflow environment. If not wouldn't I see different errors than a matplotlib import error? Thanks for the correction. – Vincent Lous Nov 27 '17 at 14:31
  • 3
    The issue was that I needed to restart the notebook in order for the installations to take effect. Why can't my successes be as glorious as my failures? – Vincent Lous Nov 27 '17 at 14:39

2 Answers2

5

The notebook needs to be restarted for the new installations to take effect.

Sushovan Mandal
  • 1,027
  • 3
  • 13
  • 32
1

You just need to upgrade matplotlib.

pip3 install -U matplotlib