0

I am working on a python program that using matplotlib. I have it installed into the program, but when I try to add "%matplotlib inline" I am getting syntax errors.

import matplotlib.pyplot as plt

%matplotlib inline

When I test with just these two lines, I am returning a syntax error on the "%". I have tried reinstalling matplotlib through pip to no avail. Any help would be appreciated.

3
  • Are you actually using a Jupyter environment? What error exactly? Commented Jun 12, 2022 at 21:09
  • My system freezes whenever I attempt to use Jupyter. I am using IDLE and have had no issues with any modules previous to this one. The error I am recieving shows "Invalid syntax" and highlights the "%" Commented Jun 12, 2022 at 21:11
  • You can't use "Jupiter magic" if you're not using Jupyter. Commented Jun 12, 2022 at 21:16

1 Answer 1

1
%matplotlib inline

is not a Python command, it's so-called IPython magic command that is working in Jupyter or pure IPython environment only. IDLE doesn't support it, and it cannot show you figures inline.

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

2 Comments

Ah that makes sense why it wouldn't be working, thank you.
@MichaelDebo you can accept an answer if it solves your problem

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.