On 19/09/17 21:13, Larry Staley wrote: > Hello I am very new to Python just having installed Python Version 2.7 onto > my windows 8.1 laptop. I thought the install was successful and was > entering information for my first assignment when I received an unexpected > error.
Where did you get your vesion of Python? If it was the standard distribution from python.org or activestate.com then it does not include any of the SciPy packages(*) and you need to install them separately. If you expect to be using mamny of these types of package you are best fetching a distribution that includes them all, for example, Anaconda or Enthought (*)Pandas is part of the SciPy suite of third party add-ons. > I executed a Sheets command using an earlier generated getSheetNames > function that successfully was entered by me. When you define a function the code inside is not executed merely compiled into a function object ready for execution. > However, when I ran the Sheets command I received the following: Its only when you call the function that the code inside gets executed. > def getSheetNames(excelfile): > from pandas import ExcelFile Its normal in Python to put all imports at the top of the file rather than inside any functions. In this case you try to import pandas everytime you call the function and while its not a big overhead it mounts up if you were calling this inside a repeating loop. And if the import was outside the function you would pick up the import error earlier. >>>> excelfile=r:"C:\Users\Larry >>>> sheets=getSheetNames > (excelfile);sheets I'm not sure what you are doing with that final ;sheets. I assuyme trying to evaluate the result of the function? It would be normal to just print it: >>> print getSheetNames(excelFile) or, if you need to store the result: >>> sheets=getSheetNames(excelfile) >>> sheets Combining commands on a single line doesn't save much typing and makes debugging harder. > I have in addition included the actual Python I executed and received the > message. It is attached in the file. attachments often get rejected by the mailer, if its not a huge file(>100 lines) just paste it into the email. Always include the full error trace too. > If I need to install Pandas, please indicate clearly how I do using my > current ver 2.7 python install. The easiest way is just to grab one of the all-inclusive Python distros mentioned above. -- 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 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor