ImportError: No module named matplotlib.pyplot

后端 未结 13 906
春和景丽
春和景丽 2020-11-28 02:03

I am currently practicing matplotlib. This is the first example I practice.

#!/usr/bin/python

import matplotlib.pyplot as plt

radius = [1.0, 2.0, 3.0, 4.0]         


        
13条回答
  •  醉梦人生
    2020-11-28 02:56

    You have two pythons installed on your machine, one is the standard python that comes with Mac OSX and the second is the one you installed with ports (this is the one that has matplotlib installed in its library, the one that comes with macosx does not).

    /usr/bin/python
    

    Is the standard mac python and since it doesn't have matplotlib you should always start your script with the one installed with ports.

    If python your_script.py works then change the #! to:

    #!/usr/bin/env python
    

    Or put the full path to the python interpreter that has the matplotlib installed in its library.

提交回复
热议问题