>>> %matplotlib inline results in SyntaxError: invalid syntax

Chris Grace cgrace.chris at gmail.com
Mon Dec 25 15:26:19 EST 2023


"%matplotlib inline" is a magic command that changes how plots render when
working with IPython. Read more here: https://stackoverflow.com/a/43028034

The article you linked assumes you are working in an IPython shell, not
IDLE. This is common in the data science world.

You may already have IPython installed. Try running it from a command line
with `python -m IPython`. If that doesn't work, you can first install it
with `python -m pip install IPython`, then run the 1st command.

IPython is commonly used as a Jupyter Notebook kernel. See
https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/index.html
for more information about Jupyter Notebook.

I'd also recommend a newer version of python. Python 3.4 reached end of
life almost 5 years ago. Some of the packages used in the linked article no
longer officially support python 3.4. That doesn't necessarily mean that
you'll experienced issues using python 3.4, but much has changed in the 7
years since that article was written.

On Mon, Dec 25, 2023, 2:53 PM Alan Gauld via Python-list <
python-list at python.org> wrote:

> On 25/12/2023 05:34, geetanajali homes via Python-list wrote:
>
> >> import numpy as np
> >> import pandas as pd
> >> import random
> >> import matplotlib.pyplot as plt
> >> %matplotlib inline
> >>
> >> I get an error on the last line. I am running this code in Idle Python
> >> 3.4.4 Shell...
>
> Python names can't start with a % (its the modulo or
> string formatting operator).
>
> I know nothing of the innards of matplotlib so I can only
> suggest a closer examination of their tutorial information.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list