No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

前端 未结 5 1024
刺人心
刺人心 2021-01-13 08:25

Have found a similar issue, however haven\'t found proper solution.

Here\'s a code:

import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,2,5])
plt.sh         


        
相关标签:
5条回答
  • 2021-01-13 08:56

    simply install:

    python -m pip install -U pip
    python -m pip install -U matplotlib
    
    0 讨论(0)
  • 2021-01-13 08:59

    I had the same problem reasons in my case were

    1. python 3.8.2 with matplotlib that I downloaded was for 3.7. Make sure they are the same.

    2. python 64 bits version with matplotlib 32bits. Make sure they are the same

      Use python -m pip install package_which_you_need to install packages for Windows

    3. Make sure to add to PATH the environment variables I forgot to do in my case

    4. pip version was old use Use python -m pip install --upgrade pip to upgrade pip to the latest for Windows

    5. I saved the file name as matplotlib.py. Try to avoid that

    6. Finally I typed matplotlib.pyplot as matplotlib.plyplot remember to check for typos first. The error message looks similar even though I corrected all the steps above.

      ModuleNotFoundError: No module named 'matplotlib.pyplot'

      ModuleNotFoundError: No module named 'matplotlib.plyplot'

    0 讨论(0)
  • 2021-01-13 09:06

    If you are using pycharm and have matplotlib.py in your current working directory than you get this error. Just delete or rename the matplotlib.py file and it will work.

    0 讨论(0)
  • 2021-01-13 09:08

    don't name any file as matplotlib.py within your working directory

    0 讨论(0)
  • 2021-01-13 09:10

    In your working directory, check if there is any file matplotlib.py Delete that file and import matplotib again. That should work.

    0 讨论(0)
提交回复
热议问题