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

前端 未结 5 1288
刺人心
刺人心 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: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'

提交回复
热议问题