Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

from matplotlib import style ImportError: cannot import name 'style'

I am receiving the following error message

ImportError: cannot import name 'style'

when I run

from matplotlib import style

I am using ubuntu and have tried running it with python3 and python. I have version (1.3.1) of matplotlib installed, which is the most up-to-date that apt-get installs. I have installed numpy and installed matplotlib with python3. No joy.

Has anybody else been having the same issue ?

like image 919
Steve Avatar asked Sep 24 '15 13:09

Steve


3 Answers

sudo pip install --upgrade matplotlib

Did the trick. Although on my machine it initially threw up some issues. There are a number of helpful suggestions on this thread for anyone else having the issue

ubuntu 14.04, pip cannot upgrade matplotllib

like image 119
Steve Avatar answered Oct 16 '22 19:10

Steve


You can also use pip install --user --upgrade matplotlib

Using sudo is deemed unsafe as you're allowing pip to execute code from the internet as root.

Using --user :

..makes pip install packages in your home directory instead, which doesn't require any special privileges Purpose of --user

More information on this here: What are the risks of running 'sudo pip'?

like image 2
SenatorWaffles Avatar answered Oct 16 '22 20:10

SenatorWaffles


I had the same problem using Anaconda and IPython 3.1. You can update matplotlib to its latest version after you have installed Anaconda. Just remind that you may want to use the installer for Python 3. You will find the style module by using both the matplotlib library and matplotlib.pyplot.

like image 1
Fabrizio Avatar answered Oct 16 '22 20:10

Fabrizio