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

Chris Angelico rosuav at gmail.com
Fri Jan 29 02:32:58 EST 2016


On Fri, Jan 29, 2016 at 6:04 PM, Mike S via Python-list
<python-list at python.org> wrote:
>
> I get an error on the last line. I am running this code in Idle Python 3.4.4
> Shell...
>
> Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> import numpy as np
>>>> import pandas as pd
>>>> import random
>>>> import matplotlib.pyplot as plt
>>>> %matplotlib inline
> SyntaxError: invalid syntax
>
> What am I doing wrong? Suggested reading?

That's a magic command for ipython - it's not actual Python syntax.
You can either install ipython and do the exercises there, or continue
with Idle and accept that things will be slightly different. Skim
through a few more of the examples; do you see more lines starting
with percent signs? If not, you can probably get away with using any
interactive Python interpreter (including Idle as you're using above).
Alternatively, take the certain route and install ipython - then
everything should work.

ChrisA



More information about the Python-list mailing list