0

I am very new to programming so bear with me. I am trying to import matplotlib . I have matplotlib already on my computer. When I

import matplotlib.pyplot as plt

I get

ModuleNotFoundError: No module named 'matplotlib'

I have tried to uninstall and reinstalled matplot lib using pip and pip3 multiple times. When I uninstall I get this and then reinstall I get this:

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\...

I have also tried uninstalling and reinstalling python but that doesn't seem to do anything. What can I do to fix this? I am using the most recent version of Python.

2
  • can you please specify your environment, whether linux or mac or any other ? Commented Jul 5, 2020 at 2:25
  • @kirtipurohit Windows Commented Jul 5, 2020 at 2:26

1 Answer 1

1

If you have multiple python editors, make sure you installed matplotlib with the pip.exe from the python editor you are trying to import matplotlib.pyplot in.

Make the pip.exe you are using in a folder called Scripts is in the folder that contains to python editor of interest.

For example, the pip.exe from Pycharm could be 'C:\Users\User\jetbrains\AppData\Roaming\Python\Python37\Scripts', while the pip.exe from spyder could be 'C:\Users\User\Anaconda3\Scripts'.

Sign up to request clarification or add additional context in comments.

10 Comments

Make the pip is in a folder called Scripts that is in the folder that contains to python editor of interest.
@MartinChapman For example, the pip.exe from Pycharm could be 'C:\Users\User\jetbrains\AppData\Roaming\Python\Python37\Scripts', while the pip.exe from spyder could be 'C:\Users\User\Anaconda3\Scripts'.
This sort of problem is why I recommend learning how to interact with python via a command line interface (and a simple text editor) before graduating to an IDE. IDE's are very helpful, but they do hide some of the important background information from you.
you can easily find where your python is by calling import sys;print(sys.executable), and you can find where pip is by opening up cmd (not powershell) and calling where pip
@AnnZen I can actually just install matplotlib through pycharm itself without using the cmd prompt. Thank you for your help.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.