app engine: ImportError: No module named Crypto.Hash

后端 未结 2 933
误落风尘
误落风尘 2021-01-17 13:51

I have a script that uses Crypto.Hash but import fails with error:

ImportError: No module named Crypto.Hash

in my sys.pa

相关标签:
2条回答
  • 2021-01-17 14:21

    Run the SDK from the command line with dev_appserver.py, rather than with the GUI (assuming you've already checked that it's installed via pip).

    I've seen similar problems with App Engine not importing libraries locally, even though they're installed, and even though they work fine in production. MySQLDB comes to mind, although I can't find the reference. Anyway, this worked for me.

    0 讨论(0)
  • 2021-01-17 14:39

    It seems a problem that happens on MAC OSX, all I have managed to do is following:

    firstly you need to know where your install of pycripto is, running

    sudo pip install pycrypto
    

    either you install the library or you get the path where it is installed

    Requirement already satisfied (use --upgrade to upgrade): pycrypto in ...

    then, considering that this is a problem that does not happen in production on 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
    
    0 讨论(0)
提交回复
热议问题