Sure, here is the traceback, and I attach the controller that generates it
(line 66 is just from sympy import *:
1. 2013-06-24 23:28:15.534 /myeducenter/worksheets/fractions1topdf 500
3419ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
95.121.196.14 - - [24/Jun/2013:14:28:15 -0700] "GET
/myeducenter/worksheets/fractions1topdf HTTP/1.1" 500 384 - "Mozilla/5.0
(Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/27.0.1453.116 Safari/537.36" "myeduapps.appspot.com" ms=3419 cpu_ms=2014
cpm_usd=0.000043 loading_request=1 app_engine_release=1.8.1
instance=00c61b117cc9d943618bc9990d62cb26442171
<https://appengine.google.com/instances?app_id=s~myeduapps&version_id=2.368322769822934897&key=00c61b117cc9d943618bc9990d62cb26442171#00c61b117cc9d943618bc9990d62cb26442171>
2. E2013-06-24 23:28:15.532
In FILE:
/base/data/home/apps/s~myeduapps/2.368322769822934897/applications/myeducenter/controllers/worksheets.py
Traceback (most recent call last):
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/gluon/restricted.py",
line 212, in restricted
exec ccode in environment
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/applications/myeducenter/controllers/worksheets.py",
line 250, in <module>
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/gluon/globals.py", line
194, in <lambda>
self._caller = lambda f: f()
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/applications/myeducenter/controllers/worksheets.py",
line 66, in fractions1topdf
from sympy import *
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/gluon/custom_import.py",
line 87, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/myeducenter/modules/sympy/__init__.py", line 49, in
<module>
from sympy.core import *
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/gluon/custom_import.py",
line 87, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
File "applications/myeducenter/modules/sympy/core/__init__.py", line 8, in
<module>
from expr import Expr, AtomicExpr
File
"/base/data/home/apps/s~myeduapps/2.368322769822934897/gluon/custom_import.py",
line 87, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named expr
3. E2013-06-24 23:28:15.533
/base/data/home/apps/s~myeduapps/2.368322769822934897/applications/myeducenter/controllers/worksheets.py:51:
SyntaxWarning: import * only allowed at module level
4. E2013-06-24 23:28:15.533
def fractions1topdf():
5. E2013-06-24 23:28:15.533
/base/data/home/apps/s~myeduapps/2.368322769822934897/applications/myeducenter/controllers/worksheets.py:160:
SyntaxWarning: import * only allowed at module level
Cheers
Pablo
El lunes, 24 de junio de 2013 23:01:14 UTC+2, Aaron Meurer escribió:
>
> That's because locally, it just uses your Python, without sandboxing
> it. It doesn't remove the modules that aren't there in the App Engine.
>
> I'm not sure why it works in SymPy Live. You can see if there is
> something in the source (https://github.com/sympy/sympy-live/).
>
> The reason I asked about Python 2.7 is that (in master at least), only
> the Python 2.5 parser users the parser module.
>
> Can you post a traceback that you get from the app engine logs (on the
> dashboard)?
>
> Aaron Meurer
>
> On Mon, Jun 24, 2013 at 3:28 PM, peibol <[email protected] <javascript:>>
> wrote:
> > Yes
> >
> > More details... my app is web2py based and I'm importing sympy as a
> module.
> > The weird thing is that it works in local. I attach my app.yaml.
> >
> > Thanks for the reply.
> >
> >
> > El lunes, 24 de junio de 2013 22:23:31 UTC+2, Aaron Meurer escribió:
> >>
> >> Are you using Python 2.7 in the App Engine?
> >>
> >> Aaron Meurer
> >>
> >> On Mon, Jun 24, 2013 at 2:03 PM, peibol <[email protected]> wrote:
> >> > Hi there, some update in my progress. I've managed to run the
> sympy-live
> >> > in
> >> > my appengine, so it's clear that not only sympify work in GAE, but
> the
> >> > full
> >> > sympy.
> >> >
> >> > But I don't know how to made the imports in order to make sympy work
> in
> >> > my
> >> > app, which in local works fine. Are there any dependences that I'm
> >> > missing?
> >> >
> >> > Thanks!
> >> >
> >> >
> >> > El lunes, 24 de junio de 2013 10:07:49 UTC+2, peibol escribió:
> >> >>
> >> >> Hi all
> >> >> When running in GAE, i get the error "Cannot import module simpify",
> >> >> while
> >> >> in local it runs great. Is any other way to proceed with sympy
> without
> >> >> making use of simpify? I've read it's a parser problem here, but I'm
> >> >> missing
> >> >> something beacuse for example the sympy live runs on GAE.
> >> >>
> >> >> More details about what I need to do. I want to make math
> worksheets,
> >> >> so I
> >> >> need to deal with algebraic expressions and then susbtitute
> variables
> >> >> by
> >> >> concrete values, both to calculate the result and to print the latex
> >> >> expression. Here is an example to print 1/2+2/4 from the expression
> >> >> a/b+c/d
> >> >> and calculating the result (3/4)
> >> >>
> >> >>
> >> >> a,b,c,d = symbols('a b c d')
> >> >> fvars = [a,b,c,d]
> >> >> values = [1,4,2,4]
> >> >> exp=sympify('a/b + c/d')
> >> >> res=nsimplify(exp.evalf(subs = dict(zip(fvars,values)))) #this is
> the
> >> >> result: 3/4
> >> >> a = sympify(1)
> >> >> b = sympify(4)
> >> >> c = sympify(2)
> >> >> d = sympify(4)
> >> >>
> >> >> exp=exp.subs([(var, Symbol("%s" % i)) for var, i in zip(fvars,
> >> >> values)])
> >> >> straux=urllib.quote(printing.latex(exp))
> >> >>
> >> >>
> >> >> strchart='
> http://chart.apis.google.com/chart?cht=tx&chs=140x50&chf=bg,s,FFFFFF00&chl='
>
> >> >> + straux
> >> >>
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "sympy" group.
> >> > To unsubscribe from this group and stop receiving emails from it,
> send
> >> > an
> >> > email to [email protected].
> >> > To post to this group, send email to [email protected].
> >> > Visit this group at http://groups.google.com/group/sympy.
> >> > For more options, visit https://groups.google.com/groups/opt_out.
> >> >
> >> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "sympy" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > To post to this group, send email to [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/sympy.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.
def fractions1topdf():
import os
import sys
from sympy import *
html=markmin2html('\( \cfrac{1}{3} + \cfrac{3}{4} = \)')
class MyFPDF(FPDF, HTMLMixin):
pass
pdf=MyFPDF()
pdf.add_page()
a,b,c,d = symbols('a b c d')
fvars = [a,b,c,d]
values = [1,4,2,4]
exp= 'a/b + c/d' #Integer(3)/Integer(4) + Symbol("x")
exp = sympify(exp)
res=nsimplify(exp.evalf(subs = dict(zip(fvars,values)))) #
a = Integer(1) #sympify(1)
b = Integer(4)
c = Integer(2)
d = Integer(4)
exp=exp.subs([(var, Symbol("%s" % i)) for var, i in zip(fvars, values)])
straux=urllib.quote(printing.latex(exp))
strchart='http://chart.apis.google.com/chart?cht=tx&chs=140x50&chf=bg,s,FFFFFF00&chl=' + straux
pdf.image(strchart ,type='PNG', x=10, y=8, w=0,h=6)
pdf.set_font('Arial','B',12)
pdf.cell(40,100,str(res))
response.headers['Content-Type']='application/pdf'
return pdf.output(dest='S')