pycrypto random not supported on GAE?
Question: I have deployed a App engine application that uses pycrypto. I installed
pycrypto locally but when i deploy on the App Engine it says:

    
    
    TargetAppError: Traceback (most recent call last):
      File "/base/data/home/apps/s~shared-playground/55de226e3bc6746b0c2a029d52be624810ea0d14.376065013735366090/mimic/__mimic/target_env.py", line 968, in RunScript
        loader.load_module('__main__')
      File "/base/data/home/apps/s~shared-playground/55de226e3bc6746b0c2a029d52be624810ea0d14.376065013735366090/mimic/__mimic/target_env.py", line 316, in load_module
        return self.env.LoadModule(self, fullname)
      File "/base/data/home/apps/s~shared-playground/55de226e3bc6746b0c2a029d52be624810ea0d14.376065013735366090/mimic/__mimic/target_env.py", line 725, in LoadModule
        exec(code, module.__dict__)  # pylint: disable-msg=W0122
      File "helloworld.py", line 2, in <module>
        from pycrypto import Random
    ImportError: No module named pycrypto
    

I have the following app.yaml:

    
    
    application: my-app-id
    version: 1
    runtime: python27
    api_version: 1
    threadsafe: true
    
    handlers:
    - url: /favicon\.ico
      static_files: favicon.ico
      upload: favicon\.ico
    
    - url: /.*
      script: helloworld.app
    
    libraries:
    - name: webapp2
      version: "2.5.2"
    - name: pycrypto
      version: "2.6"
    

My code is as follows:

    
    
    import webapp2
    from Crypto.Cipher import AES
    from Crypto import Random
    
    from google.appengine.api import users
    
    class MainPage(webapp2.RequestHandler):
        def get(self):
            user = users.get_current_user()
    
            if user:
                self.response.headers['Content-Type'] = 'text/plain'
                iv = Random.new().read(AES.block_size)
                key = b'Sixteen byte key'
                cipher = AES.new(key, AES.MODE_CFB, iv)
                msg = iv + cipher.encrypt(b'Attack at dawn')
                self.response.out.write('Hello, '+ msg + ': ' + user.nickname())
    
    
            else:
                self.redirect(users.create_login_url(self.request.uri))
    
    app = webapp2.WSGIApplication([
        ('/', MainPage)
    ], debug=True)
    

The cause of the error seems fairly simple. There is no module named pycrypto.
However the following
[thread](http://stackoverflow.com/questions/12504489/pycrypto-and-google-app-
engine) suggest there is. What is the cause of this error then? Please advise
thanks.


Answer: App Engine provides third party libraries in their sandbox. Find the link[1]
below for the 3rd party libraries supported by App Engine. Also you can try to
change the version to **"latest"** instead of 2.6 in app.yaml

[1] <https://cloud.google.com/appengine/docs/python/tools/libraries27>

