cant use pyreport on windows

Asked by Ross

I'm using ipython, python 2.5 and pyreport 2.11.
I can import pyreport but dont seem to be able to get it to work.

In [25]: import pyreport
'latex' is not recognized as an internal or external command,
operable program or batch file.
'pdflatex' is not recognized as an internal or external command
operable program or batch file.

Out[26]: <module 'pyreport' from 'pyreport.pyc'>

In [27]: pyreport test.py
----------------------------
   File "<ipython console>", line 1
     pyreport test.py
                ^
SyntaxError: invalid syntax

contents of test.py

#!/usr/bin/env python
from scipy import *
from pylab import *
#from pylab import imshow
#!
#! Some graphical explorations of the Julia sets with python and pyreport
#!#########################################################################
#$
#$ We start by defining a function J:
#$ \[ J_c : z \rightarrow z^2 + c \]
#$
def J(c):
    return lambda z : z**2 + c

[x,y] = ogrid[ -1:1:0.002, -1:1:0.002 ]
z = x + y *1j
#! If we study the divergence of function J under repeated iteration
#! depending on its inital conditions we get a very pretty graph
threshTime = zeros_like(z)
for i in range(40):
    z = J(0.285)(z)
    threshTime += z*conj(z) > 4
figure(0)
axes([0,0,1,1])
axis('off')
imshow(threshTime)
bone()
show()
#! We can also do that systematicaly for other values of c:
axes([0,0,1,1])
axis('off')
rcParams.update({'figure.figsize': [10.5,5]})
c_values = (0.285 + 0.013j, 0.45 - 0.1428j, -0.70176 -0.3842j,
    -0.835-0.2321j, -0.939 +0.167j, -0.986+0.87j)
for i,c in enumerate(c_values):
    threshTime = zeros_like(z)
    z = x + y *1j
    for n in range(40):
        z = J(c)(z)
        threshTime += z*conj(z) > 4
    subplot(2,3,i+1)
    imshow(threshTime)
    axis('off')
show()

Question information

Language:
English Edit question
Status:
Answered
For:
pyreport Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Gael Varoquaux (gael-varoquaux) said :
#1

Hi Ross,

The two messages about Latex are no problem, they are normal.
Your problem is that pyreport is not meant to be called from Python. This is a pure oversight from my part (though even if I had devised it to be called from Python, you would not be able to do it the way you are trying.

Python is directly called from the command line. In ipython you can do "!python pyreport test.py". I think this should work, even under windows. Please tell me if it does, or if you need more help.

Revision history for this message
Ross (r-ashman-yahoo) said :
#2

Thanks for the quick reply.

I tried what you suggested without success. From the command line I get:
'pyreport' is not recognized as an internal or external command,operable program or batch file.

I get the same thing from ipython using "!"

I have my path set to c:\Python24 and I put pyreport in that directory

Am I missing something?

Revision history for this message
Ross (r-ashman-yahoo) said :
#3

Ok I now have something kind of working.

The syntax used in ipython was
run pyreport 'mytest.py'

mytest looks like this:
#!/usr/bin/env python
from scipy import *
from pylab import *
#from pylab import imshow
#!
#! Some graphical explorations of the Julia sets with python and pyreport
#!#########################################################################
#$
#$ We start by defining a function J:
#$ \[ J_c : z \rightarrow z^2 + c \]
#$
a=arange(0,10,1)
b=arange(0,10,1)
#! If we study the divergence of function J under repeated iteration
#! depending on its inital conditions we get a very pretty graph
plot(a,b)
show()
#! We can also do that systematicaly for other values of c:

the output looks like this:
#!/usr/bin/env python
from scipy import *
from pylab import *
#from pylab import imshow

#$
#$ We start by defining a function J:
#$ \[ J_c : z \rightarrow z^2 + c \]
#$
a=arange

Something very wrong going on here. Not sure what.
The plot is generated but is linked into the html page.

Any hints or tips?

Revision history for this message
Gael Varoquaux (gael-varoquaux) said :
#4

On Wed, Jan 16, 2008 at 04:57:18AM -0000, Ross wrote:
> I tried what you suggested without success. From the command line I get:
> 'pyreport' is not recognized as an internal or external command,operable program or batch file.

Yup, that's why I suggested "python pyreport ...", and not "pyreport
...". Windows does not know how to call a Python program. But your
workaround is a very nice idea. I'll answer to your other question on the
other thread.

Gaël

Revision history for this message
Gael Varoquaux (gael-varoquaux) said :
#5

On Wed, Jan 16, 2008 at 06:17:26AM -0000, Ross wrote:
> The syntax used in ipython was
> run pyreport 'mytest.py'

Good idea. I like it. I'll add the suggestion on the webpage when I find
time.

> mytest looks like this:
> #!/usr/bin/env python
> from scipy import *
> from pylab import *
> #from pylab import imshow
> #!
> #! Some graphical explorations of the Julia sets with python and pyreport
> #!#########################################################################
> #$
> #$ We start by defining a function J:
> #$ \[ J_c : z \rightarrow z^2 + c \]
> #$
> a=arange(0,10,1)
> b=arange(0,10,1)
> #! If we study the divergence of function J under repeated iteration
> #! depending on its inital conditions we get a very pretty graph
> plot(a,b)
> show()
> #! We can also do that systematicaly for other values of c:

> the output looks like this:
> #!/usr/bin/env python
> from scipy import *
> from pylab import *
> #from pylab import imshow

> #$
> #$ We start by defining a function J:
> #$ \[ J_c : z \rightarrow z^2 + c \]
> #$
> a=arange

> Something very wrong going on here. Not sure what.

OK, I think I got it. This is the first title encounter, and it must have
been transformed into the page title. Try putting these line twice, the
first are for the page title, and the second for putting a title there.
Sorry, this is how docutils work, I can't control this.

> The plot is generated but is linked into the html page.

Ugly. That's simply not right. I must admit I haven't been clean enough
with my versionning to know exactly which code the version of pyreport
that you are using corresponds. Can you send me ( gael _dot_ varoquaux
_at_ normalesup _dot_ org ) the pyreport.py you are using, the html file
generated, as well as tell me what """
import docutils
docutils.__version__
"""
returns.

Cheers,

Gaël

Can you help with this problem?

Provide an answer of your own, or ask Ross for more information if necessary.

To post a message you must log in.