Run Python Script; Nothing Happens

Todd toddrjen at gmail.com
Wed Jul 29 09:25:22 EDT 2015


On Wed, Jul 29, 2015 at 3:19 PM, ryguy7272 <ryanshuell at gmail.com> wrote:

> I am using Spyder Python 2.7.  I'm running this sample code.
> import numpy as np
> import numpy.random as npr
> import matplotlib.pyplot as plt
> S0 = 100
> r = 0.05
> sigma = 0.25
> T = 30 / 365.
> I = 10000
> ST = S0 * np.exp((r - 0.5 * sigma ** 2) * T + sigma * np.sqrt(T) *
> npr.standard_normal(I))
> R_gbm = np.sort(ST - S0)
> plt.hist(R_gbm, bins=50)
> plt.xlabel('absolute return')
> plt.ylabel('frequency')
> plt.grid(True)
>
> I found it in a book, and I'm trying to run various samples of code, in an
> effort to learn Python.  So, I click the debug button, and this is what I
> get.
> > c:\users\rshuell001\untitled12.py(1)<module>()
> -> import numpy as np
> (Pdb)
>
> It seems like it doesn't really do anything.  So, I click the exit debug
> button and then click the run button and nothing happens.  I get nothing at
> all.  In the book, the author got a graph.  I get nothing.  I think, and I
> could be totally wrong, Python is sending something to a Console, but I
> can't tell where it goes.  I opened every Console I could find, and I still
> see nothing happening whatsoever.
>
> Any idea what's wrong here?
>
>
First, you need to call plt.show() at the end in order to see anything.

Second, when you run the debugger it immediately waits for you to tell it
what to do.  So you need to tell it continue running.  But normally you
wouldn't run it in the debugger.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150729/4b53a747/attachment.html>


More information about the Python-list mailing list