Application Engine: ImportError: no module named Crypto.Hash

I have a script that uses Crypto.Hash , but the import fails:

 ImportError: No module named Crypto.Hash 

in my sys.path , if I print a list of sys.path , there is this entry (among other things):

 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/pycrypto-2.6 

If I open the path above there is no pycrypto-2.6 directory.

How can I download pycrypto 2.6?

If I import Crypto.Hash running python from the command line, it works

I must indicate that pycrypto is supported by App Engine, it is included in this list .

In addition, I included the module in my app.yaml file:

 libraries: - name: webapp2 version: "2.5.2" - name: pycrypto version: latest - name: lxml version: "2.3" - name: ssl version: latest 

If I send the code during production to appengine, it works, the problem is on my system, I should probably download the compiled version of pycrypto and put it somewhere appengine can use it

+6
source share
2 answers

It seems that the problem that occurs in MAC OSX, all I managed to do is the following:

firstly you need to know where your pycripto installation is located by running

 sudo pip install pycrypto 

either you install the library, or you get the path on which it is installed

The requirement has already been met (use --upgrade to upgrade): pycrypto in ...

then, given that this is a problem that does not occur when producing appengine, I did this:

 try: from Crypto.Hash import SHA except ImportError: import sys sys.path.append('/[mypath]/anaconda/lib/python2.7/site-packages') from Crypto.Hash import SHA # requires PyCrypto 
+6
source

Run the SDK from the command line with dev_appserver.py , and not with the graphical interface (if you have already verified that it is installed via pip ).

I saw similar problems when the App Engine did not import the libraries locally, even if they were installed, and even though they worked fine in the production process. MySQLDB comes to mind, although I cannot find the link. Anyway, it worked for me.

0
source

All Articles