今天在装matplotlib的时候,用的是pip命令安装的,命令为:
pip install matplotlib
但是不幸的是,运行程序的时候还是报错,错误信息为:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from main import speechRecorder
File "/Users/admin/Documents/pythonFiles/CASR-DEMO/speechV2.0/main/speechRecorder.py", line 4, in <module>
from main import CASR_model
File "/Users/admin/Documents/pythonFiles/CASR-DEMO/speechV2.0/main/CASR_model.py", line 11, in <module>
from .SpeechModel251 import ModelSpeech
File "/Users/admin/Documents/pythonFiles/CASR-DEMO/speechV2.0/main/SpeechModel251.py", line 10, in <module>
from general_function.file_wav import *
File "/Users/admin/Documents/pythonFiles/CASR-DEMO/speechV2.0/general_function/file_wav.py", line 7, in <module>
import matplotlib.pyplot as plt
File "/Users/admin/anaconda3/envs/speech/lib/python3.5/site-packages/matplotlib/pyplot.py", line 2371, in <module>
switch_backend(rcParams["backend"])
File "/Users/admin/anaconda3/envs/speech/lib/python3.5/site-packages/matplotlib/pyplot.py", line 207, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/Users/admin/anaconda3/envs/speech/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/admin/anaconda3/envs/speech/lib/python3.5/site-packages/matplotlib/backends/backend_macosx.py", line 14, in <module>
from matplotlib.backends import _macosx
ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
解决方法
conda install matplotlib
参考文献
[1].Anaconda下安装matplotlib的方法(3). https://www.jianshu.com/p/0d166eb781f3