Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On 2023-12-25 19:53, Alan Gauld via Python-list 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. I believe it's a feature of Jupyter specifically. It won't work in IDLE. -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On Tue, 26 Dec 2023 at 07:27, Chris Grace via Python-list wrote: > I'd also recommend a newer version of python. Python 3.4 reached end of > life almost 5 years ago. Uhh, putting this in perspective... until a spammer revived the thread just now, it was asked, answered, and finished with, all back in 2016. I don't think anyone's still waiting on answers here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
"%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@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 > -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
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
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On Friday 29 January 2016 at 12:34:47 UTC+5:30, Mike S wrote: > I have installed Python 3.4.4 on XPSP3 and am trying to work my way > through this tutorial. > > A Complete Tutorial on Ridge and Lasso Regression in Python > http://www.analyticsvidhya.com/blog/2016/01/complete-tutorial-ridge-lasso-regression-python/ > > > In Step 2 "Why Penalize the Magnitude of Coefficients?" we are shown > this code: > > #Importing libraries. The same will be used throughout the article. > 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 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? > TIA, > Mike best commercial property in noida... https://sayastatus129.in/ https://sikkamallnoida.com/ https://paras133.com/ https://gygynoida.in/ https://experion45noida.in/ https://krasacentrade.com/ -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On Fri, 29 Jan 2016 06:04 pm, Mike S wrote: > %matplotlib inline > > 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 %matplotlib looks to me like iPython "magic" -- yes, that's the official name for it. It's not real Python code, and won't run in a regular Python interpreter like IDLE. IPython is a custom Python interactive interpreter. As well as running regular Python code, it includes special syntax for magic such as: %cd %run %bg and many more. http://ipython.org/ipython-doc/rel-0.10.2/html/interactive/reference.html#magic You could try installing iPython and running the tutorial examples in that, or perhaps finding a better tutorial that actually bothers to mention what it needs to run. (You have read the tutorial from the beginning, yes?) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On 1/28/2016 11:57 PM, Steven D'Aprano wrote: On Fri, 29 Jan 2016 06:04 pm, Mike S wrote: %matplotlib inline 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 %matplotlib looks to me like iPython "magic" -- yes, that's the official name for it. It's not real Python code, and won't run in a regular Python interpreter like IDLE. IPython is a custom Python interactive interpreter. As well as running regular Python code, it includes special syntax for magic such as: %cd %run %bg and many more. http://ipython.org/ipython-doc/rel-0.10.2/html/interactive/reference.html#magic You could try installing iPython and running the tutorial examples in that, or perhaps finding a better tutorial that actually bothers to mention what it needs to run. (You have read the tutorial from the beginning, yes?) Thank you Chris and Steven, I'll see if I can get iPython running and do a tutorial. -- https://mail.python.org/mailman/listinfo/python-list
Re: >>> %matplotlib inline results in SyntaxError: invalid syntax
On Fri, Jan 29, 2016 at 6:04 PM, Mike S via Python-listwrote: > > 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 -- https://mail.python.org/mailman/listinfo/python-list