Which web2py version? Is the module in a modules folder or installed in site-packages?
Here is a possibility. 1.99.7 erroneously returns import error if the module fails. The module may fail to import because of a missing dependency. A path issue or a permission issue. On Friday, 25 May 2012 14:19:08 UTC-5, Yarin wrote: > > For the first time I'm having trouble importing a module in web2py that > imports normally elsewhere. I can't understand why this would be so. > > I'm trying to use the SendGrid Python API. I have the sendgrid library in > my modules folder like all my other modules, and I was trying to import per > the sample code, but get a > <type 'exceptions.NameError'> name 'sendgrid' is not defined > error. > > But when I do the same import from a flat file using the command line, it > runs fine. > > Here is my controller code, and the sendgrid library is > here<https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid> > . > > def test(): > import sendgrid > > return 'import worked' > > >