I am using a Mac,
I try to use the ggplot as follow
import matplotlib.pyplot as plt
plt.style.use('ggplot')
but I am always getting an error like
File "/Users/Desktop/code.py", line 4, in <module>
plt.style.use('ggplot')
AttributeError: 'module' object has no attribute 'style'
I have been checking to find a solution but I don't know where i am making a mistake. Any comment ?
As mentioned blow, I must upgrade the matplotlib
however, I am getting error
My python version is 2.7
so I tried this
pip2 install matplotlib
and here are the errors
Requirement already satisfied: matplotlib in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requirement already satisfied: numpy>=1.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: tornado in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already satisfied: pyparsing>=1.5.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: nose in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages/singledispatch-3.4.0.3-py2.7.egg (from tornado->matplotlib)
Requirement already satisfied: certifi in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied: backports_abc>=0.4 in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado->matplotlib)
Or I tried
sudo port install py27-pip
and here are the errors
Password:
Error: Current platform "darwin 16" does not match expected platform "darwin 15"
Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration
OS platform mismatch
while executing
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch
or I tried this
python get-pip.py
#Requirement already up-to-date: pip in /Library/Python/2.7/site-packages
then
pip install matplotlib
the errors are the following
Requirement already satisfied: matplotlib in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requirement already satisfied: numpy>=1.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: tornado in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already satisfied: pyparsing>=1.5.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib)
Requirement already satisfied: nose in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages/singledispatch-3.4.0.3-py2.7.egg (from tornado->matplotlib)
Requirement already satisfied: certifi in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied: backports_abc>=0.4 in /Library/Python/2.7/site-packages (from tornado->matplotlib)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado->matplotlib)
pip2 install -U matplotlib
or
sudo pip2 install -U matplotlib
It gives me a lot of error just few lines at the bottom blew
('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz/zoneinfo', '/var/folders/0y/736q6sd901z27bmpx9nwn_p40000gn/T/pip-r5YiwW-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz/zoneinfo', "[Errno 1] Operation not permitted: '/var/folders/0y/736q6sd901z27bmpx9nwn_p40000gn/T/pip-r5YiwW-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz/zoneinfo'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz', '/var/folders/0y/736q6sd901z27bmpx9nwn_p40000gn/T/pip-r5YiwW-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz', "[Errno 1] Operation not permitted: '/var/folders/0y/736q6sd901z27bmpx9nwn_p40000gn/T/pip-r5YiwW-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz'")]
The same if I do with sudo
"[Errno 1] Operation not permitted: '/tmp/pip-5PMqIK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pytz'")]