the message "cannot import ..." often implies "cannot locate" rather than "there's something wrong with the file or the importer's capabilities"
what you are describing suggests that the ast module is in the python path associated with your script (the one at /usr/bin/python, which is the one used if you invoked the script with "./my_test_script.py") and not in the path of the python you are running web2py with; try "which python" at command line to identify the one being used if you are starting web2py with "python web2py.py ..." start python at command line and try importing ast and see what results; On Friday, July 19, 2013 8:09:40 AM UTC-5, Auden RovelleQuartz wrote: > > on regular python - for example on a www.compilr.com account, I am able > to create and successfully execute this trivial program (in the {} brackets: > > { > > #!/usr/bin/python > > import ast > l = ast.literal_eval('["a","31","c"]') > l = [i.strip() for i in l] > print l[1] > > } > > > but when I try to use the ast module within the web2py framework as in > this controller function: > > { > > def index(): > import ast > rec = db(db.audentest.id > 0).select() > item = rec[0] > l = ast.literal_eval(item) > l = [i.strip() for i in l] > quantity1 = l > link = A("Test View", _href=URL(r=request,f="testview")) > return dict(link = link, quantity1 = quantity1) > } > > I get the following error trace: > > { > > Traceback > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > 11. > 12. > > Traceback (most recent call last): > File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted > exec ccode in environment > File "/home/www-data/web2py/applications/omniavx/controllers/developer.py" > <https://omniavx.com/admin/edit/omniavx/controllers/developer.py>, line 26, > in <module> > File "/home/www-data/web2py/gluon/globals.py", line 194, in <lambda> > self._caller = lambda f: f() > File "/home/www-data/web2py/applications/omniavx/controllers/developer.py" > <https://omniavx.com/admin/edit/omniavx/controllers/developer.py>, line 2, in > index > import ast > File "/home/www-data/web2py/gluon/custom_import.py", line 81, in > custom_importer > raise ImportError, 'Cannot import module %s' % str(e) > > > } > > > Does anyone know how to import the ast module so that it works in the > web2py framework? > > Thanks > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.