-->

GAE's webapp2_extra.i18n can't import babe

2019-07-15 12:40发布

问题:

I followed the tutorial to enable i18n functionality in my GAE project:

http://webapp-improved.appspot.com/tutorials/i18n.html

However, after I easy_install the babel, I can't access my GAE due to the error:

File "/Users/myname/Developer/GAE/project/webapp2_extras/i18n.py", line 16, in <module>
    import babel
ImportError: No module named babel

And I tried to load it in my cmdline:

 $ python2.7
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import babel
>>> 

It works fine!

I suspect the problem is that GAE can't load the library, but I don't know how to solve it.

Please help, thanks!

My working environment is MaxOSX Lion, Python2.7, GAE 1.6.6.

回答1:

The doc states

For App Engine, download babel and pytz and add those libraries to your app directory.

That means you have to copy them into the app directory, not easy_install, as the SDK has import restrictions to emulate the production environment.