我从Jupyter Notebook导入matplotlib但得到以下错误。
ImportError: No module named matplotlib
设置:
Python 2 MacBook conda:4.3.30
跑完之后
conda list
它得到了:
ipykernel 4.6.1 ipython 5.3.0 matplotlib 2.0.2 np112py36_0 matplotlib 2.1.1
有人赞扬我尝试但失败了
1.
sudo apt-get install python-matplotlib
并显示
sudo: apt-get: command not found
2.
sudo apt-get install python3-matplotlib
并显示
sudo: apt-get: command not found
赞扬1和2来自这个网站
ImportError: No module named matplotlib with matplotlib installed
3.
pip install matplotlib
并显示
要求已经满足:matplotlib in ./anaconda/lib/python3.6/site-packages要求已经满足:。/ anaconda / lib / python3.6 / site-packages中的pytz(来自matplotlib)要求已经满足:cycler> = 0.10 in ./anaconda/lib/python3.6/site-packages(来自matplotlib)要求已经满足:numpy> = 1.7.1 in ./anaconda/lib/python3.6/site-packages(来自matplotlib)要求已经满足: pyparsing!= 2.0.4,!= 2.1.2,!= 2.1.6,> = 2.0.1 in ./anaconda/lib/python3.6/site-packages(来自matplotlib)要求已经满足:6> = 1.10在./anaconda/lib/python3.6/site-packages(来自matplotlib)要求已经满足:python-dateutil> = 2.0 in ./anaconda/lib/python3.6/site-packages(来自matplotlib)
从本网站推荐3
ImportError: No module named matplotlib.pyplot
更新:
跑这个
pip2 install matplotlib
它像这样成功安装
收集matplotlib下载matplotlib-2.1.1-cp27-cp27m ......成功构建subprocess32安装收集的软件包:subprocess32,six,python-dateutil,backports.functools-lru-cache,pyparsing,cycler,numpy,pytz,matplotlib成功安装了backports.functools-lru-cache-1.4 cycler-0.10.0 matplotlib-2.1.1 numpy-1.13.3 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 subprocess32-3.2。 7
然后重新启动Anaconda和Jupyter,它没有导入。
根据它的外观你已经为python3.6安装了matplot lib,只运行python3.6
而不是python
,最终运行python2。
pip通常也会为python2安装包,所以如果你想为python3安装它们,请使用pip3 install <package>
因为找不到apt-get
你可能正在运行使用yum
作为默认包管理器的CentOS。要安装,通常使用以下命令:
yum install <packagename>