[Tutor] What is wrong with my Python program that causes it to run but not give results?

Alan Gauld alan.gauld at yahoo.co.uk
Wed Oct 26 05:27:34 EDT 2016


On 26/10/16 04:19, Ed Troy wrote:
> I am pretty sure I installed python3. And, also, matplotlib, scipy, and 
> numpy. If I enter either python or python3, I get the >>>  prompt, so I 
> may have both installed.

Yes, that's normal. Ubuntu uses python 2 for some of its utilities.

> How do I verify which versions of python and 
> numpy, matplotlib and scipy I have installed? 

It looks like you have the libraries for v3 but not for v2.
Thats OK because the script you want to run is only suitable for v3.

> Would it be a help if I actually list the python program that I am 
> trying to run?

Yes. I'm assuming you just cut n paste the code from the web site but
something could have gone wrong with the fpormatting and Python is
sensitive to that, so seeing your actual code would be a good idea.


Meanwhile...

>> Go to the end of the file and modify the last segment
>> to look like:
>>
>> if __name__ == "__main__":
>>    print("Starting....")
>>    main()
>>    print("Stopping...")

Did you try that? And if so did you see either/both messages
when you ran the program under python3?

-- 
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




More information about the Tutor mailing list