[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
Tue Oct 25 19:50:26 EDT 2016


On 25/10/16 20:24, Ed Troy wrote:

> my Ubuntu machine. I created the diode IV curve data as per the article, 
> but I can't seem to get it to run.

> edward at ubuntu:~$ python LED_model_utf8.py LED_IV.txt
> Traceback (most recent call last):
>    File "LED_model_utf8.py", line 4, in <module>
>      import matplotlib.pyplot as plt
> ImportError: No module named matplotlib.pyplot

Plain 'python' on Ubuntu usually runs Python v2.
It looks like you don;t have Matplotlib inastalled for Python 2.
Matplotlib is part of the 3rd party SciPy libraries and not
part of the standard python install.

Having looked at the web page it seems you need to use python3
and have scipy, numpy and matplotlib packages installed.
You should have them in your software centre as
python3-scipy, python3-numpy and python3-matplotlib

> If I type python3 LED_model_utf8.py LED_IV.txt, there is a pause and 
> then I am back to the $ prompt. So, it seems like the program is 
> running, but I am not getting any results

That's correct. But without seeing the code and data it's
hard to guess but you could at least verify that it runs
by editing the python file to include print lines.
Go to the end of the file and modify the last segment
to look like:


if __name__ == "__main__":
  print("Starting....")
  main()
  print("Stopping...")


> The page that contains the file and a description of how it works is:
> https://leicesterraspberrypi.wordpress.com/projects/modelling-a-diode-for-use-in-spice-simulations/

I see the code but I don't see a path that
doesn't print anything... You should see some
kind of output.


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