要用 plt.style.use('ggplot') 这么一句话,发现已经装好的matplotlib版本太低,需要更新
>>> import matplotlib
>>> print matplotlib.__version__
1.3.1
运行 pip install matplotlib --upgrade --user
还是报错,不管我加sudo还是经常会用的--ignore-installed six
错误是这样的:
Collecting subprocess32 (from matplotlib)
Downloading subprocess32-3.2.7.tar.gz (54kB)
100% |████████████████████████████████| 61kB 914kB/s
Complete output from command python setup.py egg_info:
running egg_info
error: Invalid distribution name or version syntax: subprocess32-3.2.7
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-IJmXWm/subprocess32/
后来去matplotlib官网上看了一下,我简直要吐血了。。。。
macOS
If you are using Python 2.7 on a Mac you may need to do:
xcode-select --install
so that subprocess32, a dependency, may be compiled.
To use the native OSX backend you will need a framework build build of Python.
好吧,及时运行了上面这行代码,还是不行,因为我用的是mac自带的python2.7 【微笑.jpg】
好吧好吧,我认输,我用python3 【捂脸哭.jpg】