0

First, I must preface that there is an error going showing, but the normal fix isn't working. My code looks like this:

import matplotlib.pyplot as plt

x = [1,1,1]
y = [5,5,5]

plt.plot(x, y)

plt.xlabel('- Hours Spent Studying -')
plt.ylabel('- Test Scores (in %) -')

plt.title('- Science Scores -')
plt.show()

This, from what I understand about matplotlib, should graph the given points. The error that I am catching is:

import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

I immediately assumed that I had not installed matplotlib correctly or in the correct directory, so I tried going into the directory where my python39 is installed, and tried pip install matplotlib, which told me I had already installed matplotlib in the directory. Confused, I went back to my code directory and ran it again, and the same error occurred again. Does anyone have any suggestions or fixes to why this would be happening? My operating system is Win10.

1 Answer 1

1

try to run it by python3.9 code.py

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

1 Comment

Thanks! I just did "python3.9 (my file name)" and it works! Thanks so much!

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.