ModuleNotFoundError: No module named 'matplotl

2019-04-20 22:07发布

I'm trying to run a python program that requires matplotlib, which I've already installed via pip. I am running Python 3.6 locally on my Mac, with my .bash_profile updated to reflect this. The import line in question is as seen below:

import matplotlib.pyplot as plt

Below is the error message I see, as you can figure out from the subject line:

ModuleNotFoundError: No module named 'matplotlib'

And here's what I see if I try pip install matplotlib:

Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: six>=1.10 in /usr/local/lib/python3.6/site-packages (from matplotlib)

I've referenced a few other posts like this and this, but without much luck. Am I overlooking an answer that I just didn't follow through with, or could it be something else? Your time is appreciated.

2条回答
甜甜的少女心
2楼-- · 2019-04-20 22:39

Execute this from file this will work:-

import pip
pip.main(["install","matplotlib"])
查看更多
SAY GOODBYE
3楼-- · 2019-04-20 22:41

use pip3 install matplotlib to install matlplot lib. By default, pip will install those package for 2.7 as it the native one. using pip3 makes it specific for python 3, and make sure you have only one version of python 3

查看更多
登录 后发表回答